]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/tr1/test/test_function.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 <boost/type_traits/is_base_and_derived.hpp>
14 #include "verify_return.hpp"
18 int operator()()const;
19 long operator()(int)const;
20 double operator()(int, char)const;
26 void test_function(Func
*)
28 typedef typename
Func::result_type result_type
;
39 f2
= std::tr1::ref(t
);
40 f2
= std::tr1::cref(t
);
43 std::tr1::swap(f1
, f2
);
45 if(cf
&& f2
) nothing();
46 if(cf
|| f2
) nothing();
47 if(f2
&& !cf
) nothing();
49 //const std::type_info& info = cf.target_type();
50 test_functor
* func1
= f1
.template target
<test_functor
>();
51 const test_functor
* func2
= cf
.template target
<test_functor
>();
53 // comparison with null:
54 if(0 == f1
) nothing();
55 if(0 != f1
) nothing();
56 if(f2
== 0) nothing();
57 if(f2
!= 0) nothing();
63 BOOST_STATIC_ASSERT((::boost::is_base_and_derived
<std::exception
, std::tr1::bad_function_call
>::value
));
64 std::tr1::bad_function_call fe
;
66 test_function(static_cast<std::tr1::function
<int (void)>* >(0));
67 test_function(static_cast<std::tr1::function
<long (int)>* >(0));
68 test_function(static_cast<std::tr1::function
<double (int,char)>* >(0));
70 std::tr1::function
<int (void)> f1
;
71 verify_return_type(f1(), int(0));
72 std::tr1::function
<long (int)> f2
;
73 verify_return_type(f2(0), long(0));
74 std::tr1::function
<double (int, char)> f3
;
75 verify_return_type(f3(0,0), double(0));
77 //BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::unary_function<int, long>, std::tr1::function<long (int)> >::value));
78 //BOOST_STATIC_ASSERT((::boost::is_base_and_derived<std::binary_function<int, char, double>, std::tr1::function<double (int,char)> >::value));