mem_func_ptr_cv1.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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/mpl/vector.hpp>
  8. #include <boost/type_traits/is_same.hpp>
  9. #include <boost/function_types/member_function_pointer.hpp>
  10. namespace ft = boost::function_types;
  11. namespace mpl = boost::mpl;
  12. using boost::is_same;
  13. class C;
  14. typedef int (C::* expected1)(int);
  15. typedef int (C::* expected2)(int) const;
  16. typedef int (C::* expected3)(int) volatile;
  17. typedef int (C::* expected4)(int) const volatile;
  18. // implicitly specified cv qualification
  19. BOOST_MPL_ASSERT((
  20. is_same< ft::member_function_pointer< mpl::vector<int,C,int> >::type
  21. , expected1 >
  22. ));
  23. BOOST_MPL_ASSERT((
  24. is_same< ft::member_function_pointer< mpl::vector<int,C const,int> >::type
  25. , expected2 >
  26. ));
  27. BOOST_MPL_ASSERT((
  28. is_same< ft::member_function_pointer<
  29. mpl::vector<int,C volatile,int> >::type
  30. , expected3 >
  31. ));
  32. BOOST_MPL_ASSERT((
  33. is_same< ft::member_function_pointer<
  34. mpl::vector<int,C const volatile,int> >::type
  35. , expected4 >
  36. ));
  37. // implicit & explicit/overrides
  38. BOOST_MPL_ASSERT((
  39. is_same< ft::member_function_pointer<
  40. mpl::vector<int,C const volatile,int>
  41. , ft::tag<ft::non_const, ft::non_volatile> >::type
  42. , expected1 >
  43. ));
  44. BOOST_MPL_ASSERT((
  45. is_same< ft::member_function_pointer< mpl::vector<int,C volatile,int>,
  46. ft::tag<ft::const_qualified, ft::non_volatile> >::type
  47. , expected2 >
  48. ));
  49. BOOST_MPL_ASSERT((
  50. is_same< ft::member_function_pointer< mpl::vector<int,C const,int>,
  51. ft::tag<ft::non_const, ft::volatile_qualified> >::type
  52. , expected3 >
  53. ));
  54. BOOST_MPL_ASSERT((
  55. is_same< ft::member_function_pointer< mpl::vector<int,C const,int>,
  56. ft::tag<ft::const_qualified, ft::volatile_qualified> >::type
  57. , expected4 >
  58. ));
  59. BOOST_MPL_ASSERT((
  60. is_same< ft::member_function_pointer< mpl::vector<int,C volatile,int>,
  61. ft::tag<ft::const_qualified, ft::volatile_qualified> >::type
  62. , expected4 >
  63. ));
  64. BOOST_MPL_ASSERT((
  65. is_same< ft::member_function_pointer< mpl::vector<int,C volatile,int>
  66. , ft::const_qualified >::type
  67. , expected4 >
  68. ));
  69. BOOST_MPL_ASSERT((
  70. is_same< ft::member_function_pointer< mpl::vector<int,C const,int>
  71. , ft::volatile_qualified >::type
  72. , expected4 >
  73. ));