transformation.cpp 3.5 KB

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