]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/tr1/test/test_bind.cpp
1 // (C) Copyright John Maddock 2005.
2 // Use, modification and distribution are subject to the
3 // Boost Software License, Version 1.0. (See accompanying file
4 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 #ifdef TEST_STD_HEADERS
9 #include <boost/tr1/functional.hpp>
12 #include <boost/static_assert.hpp>
13 #include "verify_return.hpp"
15 // This should verify that _1 etc are lvalues, but we leave that
16 // to the "tricky" test as the Boost implementation doesn't always
19 void check_placeholder(T
)
24 //BOOST_STATIC_ASSERT(::std::tr1::is_placeholder<T>::value);
27 template <class Binder
, class R
>
28 void check_bind0(Binder b
, R r
)
30 //BOOST_STATIC_ASSERT(::std::tr1::is_bind_expression<Binder>::value);
31 verify_return_type(b(), r
);
33 typedef typename
Binder::result_type result_type
;
34 BOOST_STATIC_ASSERT((::boost::is_same
<result_type
, R
>::value
));
37 template <class Binder
, class R
, class A1
>
38 void check_bind1(Binder b
, R r
, A1 a1
)
40 //BOOST_STATIC_ASSERT(::std::tr1::is_bind_expression<Binder>::value);
41 verify_return_type(b(a1
), r
);
44 double test_proc(int a
, char b
, long c
)
57 check_placeholder(std::tr1::placeholders::_1
);
58 check_placeholder(std::tr1::placeholders::_2
);
59 check_placeholder(std::tr1::placeholders::_3
);
60 check_placeholder(std::tr1::placeholders::_4
);
61 check_placeholder(std::tr1::placeholders::_5
);
62 check_placeholder(std::tr1::placeholders::_6
);
63 check_placeholder(std::tr1::placeholders::_7
);
64 check_placeholder(std::tr1::placeholders::_8
);
65 check_placeholder(std::tr1::placeholders::_9
);
67 check_bind0(std::tr1::bind(&test_proc
, 0, 0, 0), double(0));
68 //check_bind0(std::tr1::bind<double>(&test_proc, 0, 0, 0), double(0));
69 check_bind1(std::tr1::bind(&test_proc
, 0, 0, std::tr1::placeholders::_1
), double(0), 0);
70 check_bind1(std::tr1::bind(&test_proc
, std::tr1::placeholders::_1
, 0, 0), double(0), 0);
72 check_bind0(std::tr1::bind(test_proc
, 0, 0, 0), double(0));
73 //check_bind0(std::tr1::bind<double>(test_proc, 0, 0, 0), double(0));
74 check_bind1(std::tr1::bind(test_proc
, 0, 0, std::tr1::placeholders::_1
), double(0), 0);
75 check_bind1(std::tr1::bind(test_proc
, std::tr1::placeholders::_1
, 0, 0), double(0), 0);
77 check_bind0(std::tr1::bind(std::plus
<double>(), 0, 1), double(0));
78 check_bind0(std::tr1::bind
<double>(std::plus
<double>(), 1, 0), double(0));
79 check_bind0(std::tr1::bind
<from_double
>(std::plus
<double>(), 1, 0), from_double(0));
80 check_bind1(std::tr1::bind(std::plus
<double>(), 0, std::tr1::placeholders::_1
), double(0), 0);
81 check_bind1(std::tr1::bind(std::plus
<double>(), std::tr1::placeholders::_1
, 0), double(0), 0);