is_cv_function.cpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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/function_types/is_function.hpp>
  8. namespace ft = boost::function_types;
  9. template<typename C, typename T>
  10. void test_non_cv(T C::*)
  11. {
  12. BOOST_MPL_ASSERT((
  13. ft::is_function<T, ft::non_const >
  14. ));
  15. BOOST_MPL_ASSERT((
  16. ft::is_function<T, ft::non_volatile >
  17. ));
  18. BOOST_MPL_ASSERT((
  19. ft::is_function<T, ft::tag<ft::non_const,ft::non_volatile> >
  20. ));
  21. BOOST_MPL_ASSERT_NOT((
  22. ft::is_function<T, ft::const_qualified >
  23. ));
  24. BOOST_MPL_ASSERT_NOT((
  25. ft::is_function<T, ft::volatile_qualified >
  26. ));
  27. BOOST_MPL_ASSERT_NOT((
  28. ft::is_function<T, ft::tag<ft::const_qualified,ft::volatile_qualified> >
  29. ));
  30. }
  31. template<typename C, typename T>
  32. void test_c_non_v(T C::*)
  33. {
  34. BOOST_MPL_ASSERT((
  35. ft::is_function<T, ft::const_qualified >
  36. ));
  37. BOOST_MPL_ASSERT((
  38. ft::is_function<T, ft::non_volatile >
  39. ));
  40. BOOST_MPL_ASSERT((
  41. ft::is_function<T, ft::tag<ft::const_qualified,ft::non_volatile> >
  42. ));
  43. BOOST_MPL_ASSERT_NOT((
  44. ft::is_function<T, ft::non_const >
  45. ));
  46. BOOST_MPL_ASSERT_NOT((
  47. ft::is_function<T, ft::volatile_qualified >
  48. ));
  49. BOOST_MPL_ASSERT_NOT((
  50. ft::is_function<T, ft::tag<ft::non_const,ft::volatile_qualified> >
  51. ));
  52. }
  53. template<typename C, typename T>
  54. void test_v_non_c(T C::*)
  55. {
  56. BOOST_MPL_ASSERT((
  57. ft::is_function<T, ft::non_const >
  58. ));
  59. BOOST_MPL_ASSERT((
  60. ft::is_function<T, ft::volatile_qualified >
  61. ));
  62. BOOST_MPL_ASSERT((
  63. ft::is_function<T, ft::tag<ft::non_const,ft::volatile_qualified> >
  64. ));
  65. BOOST_MPL_ASSERT_NOT((
  66. ft::is_function<T, ft::const_qualified >
  67. ));
  68. BOOST_MPL_ASSERT_NOT((
  69. ft::is_function<T, ft::non_volatile >
  70. ));
  71. BOOST_MPL_ASSERT_NOT((
  72. ft::is_function<T, ft::tag<ft::const_qualified,ft::non_volatile> >
  73. ));
  74. }
  75. template<typename C, typename T>
  76. void test_cv(T C::*)
  77. {
  78. BOOST_MPL_ASSERT((
  79. ft::is_function<T, ft::const_qualified >
  80. ));
  81. BOOST_MPL_ASSERT((
  82. ft::is_function<T, ft::volatile_qualified >
  83. ));
  84. BOOST_MPL_ASSERT((
  85. ft::is_function<T, ft::tag<ft::const_qualified,ft::volatile_qualified> >
  86. ));
  87. BOOST_MPL_ASSERT_NOT((
  88. ft::is_function<T, ft::non_const >
  89. ));
  90. BOOST_MPL_ASSERT_NOT((
  91. ft::is_function<T, ft::non_volatile >
  92. ));
  93. BOOST_MPL_ASSERT_NOT((
  94. ft::is_function<T, ft::tag<ft::non_const,ft::non_volatile> >
  95. ));
  96. }
  97. struct C
  98. {
  99. void non_cv(int) { }
  100. void c_non_v(int) const { }
  101. void v_non_c(int) volatile { }
  102. void cv(int) const volatile { }
  103. };
  104. void instanitate()
  105. {
  106. test_non_cv(& C::non_cv);
  107. test_c_non_v(& C::c_non_v);
  108. test_v_non_c(& C::v_non_c);
  109. test_cv(& C::cv);
  110. }