result_type.cpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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/result_type.hpp>
  9. namespace ft = boost::function_types;
  10. class C;
  11. typedef C func();
  12. typedef C const c_func();
  13. typedef C (*func_ptr)();
  14. typedef C const (*c_func_ptr)();
  15. typedef C (&func_ref)();
  16. typedef C const (&c_func_ref)();
  17. typedef C (C::*mem_func_ptr)();
  18. typedef C const (C::*c_mem_func_ptr)();
  19. typedef C (C::*mem_func_ptr_c)() const;
  20. typedef C const (C::*c_mem_func_ptr_c)() const;
  21. typedef C (C::*mem_func_ptr_v)() volatile;
  22. typedef C const (C::*c_mem_func_ptr_v)() volatile;
  23. typedef C (C::*mem_func_ptr_cv)() const volatile;
  24. typedef C const (C::*c_mem_func_ptr_cv)() const volatile;
  25. typedef int C::* mem_ptr;
  26. typedef int const C::* c_mem_ptr;
  27. BOOST_MPL_ASSERT((
  28. boost::is_same<ft::result_type<func>::type,C>
  29. ));
  30. BOOST_MPL_ASSERT((
  31. boost::is_same<ft::result_type<c_func>::type,C const>
  32. ));
  33. BOOST_MPL_ASSERT((
  34. boost::is_same<ft::result_type<func_ptr>::type,C>
  35. ));
  36. BOOST_MPL_ASSERT((
  37. boost::is_same<ft::result_type<c_func_ptr>::type,C const>
  38. ));
  39. BOOST_MPL_ASSERT((
  40. boost::is_same<ft::result_type<func_ref>::type,C>
  41. ));
  42. BOOST_MPL_ASSERT((
  43. boost::is_same<ft::result_type<c_func_ref>::type,C const>
  44. ));
  45. BOOST_MPL_ASSERT((
  46. boost::is_same<ft::result_type<mem_func_ptr>::type,C>
  47. ));
  48. BOOST_MPL_ASSERT((
  49. boost::is_same<ft::result_type<c_mem_func_ptr>::type,C const>
  50. ));
  51. BOOST_MPL_ASSERT((
  52. boost::is_same<ft::result_type<mem_func_ptr_c>::type,C>
  53. ));
  54. BOOST_MPL_ASSERT((
  55. boost::is_same<ft::result_type<c_mem_func_ptr_c>::type,C const>
  56. ));
  57. BOOST_MPL_ASSERT((
  58. boost::is_same<ft::result_type<mem_func_ptr_v>::type,C>
  59. ));
  60. BOOST_MPL_ASSERT((
  61. boost::is_same<ft::result_type<c_mem_func_ptr_v>::type,C const>
  62. ));
  63. BOOST_MPL_ASSERT((
  64. boost::is_same<ft::result_type<mem_func_ptr_cv>::type,C>
  65. ));
  66. BOOST_MPL_ASSERT((
  67. boost::is_same<ft::result_type<c_mem_func_ptr_cv>::type,C const>
  68. ));
  69. BOOST_MPL_ASSERT((
  70. boost::is_same<ft::result_type<mem_ptr>::type,int&>
  71. ));
  72. BOOST_MPL_ASSERT((
  73. boost::is_same<ft::result_type<c_mem_ptr>::type,int const&>
  74. ));