1 2 // (C) Copyright Tobias Schwinger 3 // 4 // Use modification and distribution are subject to the boost Software License, 5 // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt). 6 7 //------------------------------------------------------------------------------ 8 9 #include <boost/mpl/assert.hpp> 10 #include <boost/type_traits/is_same.hpp> 11 12 #include <boost/function_types/function_type.hpp> 13 #include <boost/function_types/function_pointer.hpp> 14 #include <boost/function_types/function_reference.hpp> 15 #include <boost/function_types/member_function_pointer.hpp> 16 17 namespace ft = boost::function_types; 18 namespace mpl = boost::mpl; 19 using boost::is_same; 20 21 class C; 22 23 typedef C func1(C &); 24 typedef C (*func_ptr1)(C &); 25 typedef C (&func_ref1)(C &); 26 typedef C (C::*mem_func_ptr1)(); 27 28 BOOST_MPL_ASSERT(( is_same< func1, ft::function_type<func1>::type > )); 29 BOOST_MPL_ASSERT(( is_same< func1, ft::function_type<func_ptr1>::type > )); 30 BOOST_MPL_ASSERT(( is_same< func1, ft::function_type<func_ref1>::type > )); 31 BOOST_MPL_ASSERT(( is_same< func1, ft::function_type<mem_func_ptr1>::type > )); 32 33 BOOST_MPL_ASSERT(( is_same< func_ptr1, ft::function_pointer<func1>::type > )); 34 BOOST_MPL_ASSERT(( is_same< func_ptr1, ft::function_pointer<func_ptr1>::type > )); 35 BOOST_MPL_ASSERT(( is_same< func_ptr1, ft::function_pointer<func_ref1>::type > )); 36 BOOST_MPL_ASSERT(( is_same< func_ptr1, ft::function_pointer<mem_func_ptr1>::type > )); 37 38 BOOST_MPL_ASSERT(( is_same< func_ref1, ft::function_reference<func1>::type > )); 39 BOOST_MPL_ASSERT(( is_same< func_ref1, ft::function_reference<func_ptr1>::type > )); 40 BOOST_MPL_ASSERT(( is_same< func_ref1, ft::function_reference<func_ref1>::type > )); 41 BOOST_MPL_ASSERT(( is_same< func_ref1, ft::function_reference<mem_func_ptr1>::type > )); 42 43 BOOST_MPL_ASSERT(( is_same< mem_func_ptr1, ft::member_function_pointer<func1>::type > )); 44 BOOST_MPL_ASSERT(( is_same< mem_func_ptr1, ft::member_function_pointer<func_ptr1>::type > )); 45 BOOST_MPL_ASSERT(( is_same< mem_func_ptr1, ft::member_function_pointer<func_ref1>::type > )); 46 BOOST_MPL_ASSERT(( is_same< mem_func_ptr1, ft::member_function_pointer<mem_func_ptr1>::type > )); 47 48 49 typedef C func2(C const &); 50 typedef C (*func_ptr2)(C const &); 51 typedef C (&func_ref2)(C const &); 52 typedef C (C::*mem_func_ptr2)() const; 53 54 BOOST_MPL_ASSERT(( is_same< func2, ft::function_type<func2>::type > )); 55 BOOST_MPL_ASSERT(( is_same< func2, ft::function_type<func_ptr2>::type > )); 56 BOOST_MPL_ASSERT(( is_same< func2, ft::function_type<func_ref2>::type > )); 57 BOOST_MPL_ASSERT(( is_same< func2, ft::function_type<mem_func_ptr2>::type > )); 58 59 BOOST_MPL_ASSERT(( is_same< func_ptr2, ft::function_pointer<func2>::type > )); 60 BOOST_MPL_ASSERT(( is_same< func_ptr2, ft::function_pointer<func_ptr2>::type > )); 61 BOOST_MPL_ASSERT(( is_same< func_ptr2, ft::function_pointer<func_ref2>::type > )); 62 BOOST_MPL_ASSERT(( is_same< func_ptr2, ft::function_pointer<mem_func_ptr2>::type > )); 63 64 BOOST_MPL_ASSERT(( is_same< func_ref2, ft::function_reference<func2>::type > )); 65 BOOST_MPL_ASSERT(( is_same< func_ref2, ft::function_reference<func_ptr2>::type > )); 66 BOOST_MPL_ASSERT(( is_same< func_ref2, ft::function_reference<func_ref2>::type > )); 67 BOOST_MPL_ASSERT(( is_same< func_ref2, ft::function_reference<mem_func_ptr2>::type > )); 68 69 BOOST_MPL_ASSERT(( is_same< mem_func_ptr2, ft::member_function_pointer<func2>::type > )); 70 BOOST_MPL_ASSERT(( is_same< mem_func_ptr2, ft::member_function_pointer<func_ptr2>::type > )); 71 BOOST_MPL_ASSERT(( is_same< mem_func_ptr2, ft::member_function_pointer<func_ref2>::type > )); 72 BOOST_MPL_ASSERT(( is_same< mem_func_ptr2, ft::member_function_pointer<mem_func_ptr2>::type > )); 73 74 75 76