]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/tr1/test/test_bind_tricky.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"
16 void check_placeholder( T
)
21 BOOST_STATIC_ASSERT( ::std::tr1::is_placeholder
<T
>::value
> 0 );
24 template <class Binder
, class R
>
25 void check_bind0(Binder b
, R r
)
27 BOOST_STATIC_ASSERT(::std::tr1::is_bind_expression
<Binder
>::value
);
28 verify_return_type(b(), r
);
30 typedef typename
Binder::result_type result_type
;
31 BOOST_STATIC_ASSERT((::boost::is_same
<result_type
, R
>::value
));
34 template <class Binder
, class R
, class A1
>
35 void check_bind1(Binder b
, R r
, A1 a1
)
37 BOOST_STATIC_ASSERT(::std::tr1::is_bind_expression
<Binder
>::value
);
38 verify_return_type(b(a1
), r
);
41 double test_proc(int a
, char b
, long c
)
54 check_placeholder(std::tr1::placeholders::_1
);
55 check_placeholder(std::tr1::placeholders::_2
);
56 check_placeholder(std::tr1::placeholders::_3
);
57 check_placeholder(std::tr1::placeholders::_4
);
58 check_placeholder(std::tr1::placeholders::_5
);
59 check_placeholder(std::tr1::placeholders::_6
);
60 check_placeholder(std::tr1::placeholders::_7
);
61 check_placeholder(std::tr1::placeholders::_8
);
62 check_placeholder(std::tr1::placeholders::_9
);
64 check_bind0(std::tr1::bind(&test_proc
, 0, 0, 0), double(0));
65 check_bind0(std::tr1::bind
<double>(&test_proc
, 0, 0, 0), double(0));
66 check_bind1(std::tr1::bind(&test_proc
, 0, 0, std::tr1::placeholders::_1
), double(0), 0);
67 check_bind1(std::tr1::bind(&test_proc
, std::tr1::placeholders::_1
, 0, 0), double(0), 0);
69 check_bind0(std::tr1::bind(test_proc
, 0, 0, 0), double(0));
70 check_bind0(std::tr1::bind
<double>(test_proc
, 0, 0, 0), double(0));
71 check_bind1(std::tr1::bind(test_proc
, 0, 0, std::tr1::placeholders::_1
), double(0), 0);
72 check_bind1(std::tr1::bind(test_proc
, std::tr1::placeholders::_1
, 0, 0), double(0), 0);
74 check_bind0(std::tr1::bind(std::plus
<double>(), 0, 1), double(0));
75 check_bind0(std::tr1::bind
<double>(std::plus
<double>(), 1, 0), double(0));
76 check_bind0(std::tr1::bind
<from_double
>(std::plus
<double>(), 1, 0), from_double(0));
77 check_bind1(std::tr1::bind(std::plus
<double>(), 0, std::tr1::placeholders::_1
), double(0), 0);
78 check_bind1(std::tr1::bind(std::plus
<double>(), std::tr1::placeholders::_1
, 0), double(0), 0);