cv_function_synthesis.cpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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. namespace ft = boost::function_types;
  10. namespace mpl = boost::mpl;
  11. template<typename C, typename T>
  12. void test_non_cv(T C::*)
  13. {
  14. BOOST_MPL_ASSERT(( boost::is_same<
  15. ft::function_type< mpl::vector<void,int>,
  16. ft::tag<ft::non_const,ft::non_volatile> >::type
  17. , T
  18. >));
  19. BOOST_MPL_ASSERT(( boost::is_same<
  20. ft::function_type< mpl::vector<void,int>, ft::non_const >::type
  21. , T
  22. >));
  23. BOOST_MPL_ASSERT(( boost::is_same<
  24. ft::function_type< mpl::vector<void,int>, ft::non_volatile >::type
  25. , T
  26. >));
  27. BOOST_MPL_ASSERT(( boost::is_same<
  28. ft::function_type< mpl::vector<void,int> >::type
  29. , T
  30. >));
  31. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  32. ft::function_type< mpl::vector<void,int>,
  33. ft::tag<ft::const_qualified,ft::non_volatile> >::type
  34. , T
  35. >));
  36. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  37. ft::function_type< mpl::vector<void,int>, ft::const_qualified >::type
  38. , T
  39. >));
  40. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  41. ft::function_type< mpl::vector<void,int>,
  42. ft::tag<ft::non_const,ft::volatile_qualified> >::type
  43. , T
  44. >));
  45. BOOST_MPL_ASSERT_NOT((
  46. boost::is_same<
  47. ft::function_type< mpl::vector<void,int>, ft::volatile_qualified >::type
  48. , T
  49. >));
  50. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  51. ft::function_type< mpl::vector<void,int>,
  52. ft::tag<ft::const_qualified,ft::volatile_qualified> >::type
  53. , T
  54. >));
  55. }
  56. template<typename C, typename T>
  57. void test_c_non_v(T C::*)
  58. {
  59. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  60. ft::function_type< mpl::vector<void,int>,
  61. ft::tag<ft::non_const,ft::non_volatile> >::type
  62. , T
  63. >));
  64. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  65. ft::function_type< mpl::vector<void,int>, ft::non_const >::type
  66. , T
  67. >));
  68. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  69. ft::function_type< mpl::vector<void,int>, ft::non_volatile >::type
  70. , T
  71. >));
  72. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  73. ft::function_type< mpl::vector<void,int> >::type
  74. , T
  75. >));
  76. BOOST_MPL_ASSERT(( boost::is_same<
  77. ft::function_type< mpl::vector<void,int>,
  78. ft::tag<ft::const_qualified,ft::non_volatile> >::type
  79. , T
  80. >));
  81. BOOST_MPL_ASSERT(( boost::is_same<
  82. ft::function_type< mpl::vector<void,int>, ft::const_qualified >::type
  83. , T
  84. >));
  85. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  86. ft::function_type< mpl::vector<void,int>,
  87. ft::tag<ft::non_const,ft::volatile_qualified> >::type
  88. , T
  89. >));
  90. BOOST_MPL_ASSERT_NOT((
  91. boost::is_same<
  92. ft::function_type< mpl::vector<void,int>, ft::volatile_qualified >::type
  93. , T
  94. >));
  95. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  96. ft::function_type< mpl::vector<void,int>,
  97. ft::tag<ft::const_qualified,ft::volatile_qualified> >::type
  98. , T
  99. >));
  100. }
  101. template<typename C, typename T>
  102. void test_v_non_c(T C::*)
  103. {
  104. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  105. ft::function_type< mpl::vector<void,int>,
  106. ft::tag<ft::non_const,ft::non_volatile> >::type
  107. , T
  108. >));
  109. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  110. ft::function_type< mpl::vector<void,int>, ft::non_const >::type
  111. , T
  112. >));
  113. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  114. ft::function_type< mpl::vector<void,int>, ft::non_volatile >::type
  115. , T
  116. >));
  117. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  118. ft::function_type< mpl::vector<void,int> >::type
  119. , T
  120. >));
  121. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  122. ft::function_type< mpl::vector<void,int>,
  123. ft::tag<ft::const_qualified,ft::non_volatile> >::type
  124. , T
  125. >));
  126. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  127. ft::function_type< mpl::vector<void,int>, ft::const_qualified >::type
  128. , T
  129. >));
  130. BOOST_MPL_ASSERT(( boost::is_same<
  131. ft::function_type< mpl::vector<void,int>,
  132. ft::tag<ft::non_const,ft::volatile_qualified> >::type
  133. , T
  134. >));
  135. BOOST_MPL_ASSERT((
  136. boost::is_same<
  137. ft::function_type< mpl::vector<void,int>, ft::volatile_qualified >::type
  138. , T
  139. >));
  140. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  141. ft::function_type< mpl::vector<void,int>,
  142. ft::tag<ft::const_qualified,ft::volatile_qualified> >::type
  143. , T
  144. >));
  145. }
  146. template<typename C, typename T>
  147. void test_cv(T C::*)
  148. {
  149. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  150. ft::function_type< mpl::vector<void,int>,
  151. ft::tag<ft::non_const,ft::non_volatile> >::type
  152. , T
  153. >));
  154. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  155. ft::function_type< mpl::vector<void,int>, ft::non_const >::type
  156. , T
  157. >));
  158. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  159. ft::function_type< mpl::vector<void,int>, ft::non_volatile >::type
  160. , T
  161. >));
  162. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  163. ft::function_type< mpl::vector<void,int> >::type
  164. , T
  165. >));
  166. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  167. ft::function_type< mpl::vector<void,int>,
  168. ft::tag<ft::const_qualified,ft::non_volatile> >::type
  169. , T
  170. >));
  171. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  172. ft::function_type< mpl::vector<void,int>, ft::const_qualified >::type
  173. , T
  174. >));
  175. BOOST_MPL_ASSERT_NOT(( boost::is_same<
  176. ft::function_type< mpl::vector<void,int>,
  177. ft::tag<ft::non_const,ft::volatile_qualified> >::type
  178. , T
  179. >));
  180. BOOST_MPL_ASSERT_NOT((
  181. boost::is_same<
  182. ft::function_type< mpl::vector<void,int>, ft::volatile_qualified >::type
  183. , T
  184. >));
  185. BOOST_MPL_ASSERT(( boost::is_same<
  186. ft::function_type< mpl::vector<void,int>,
  187. ft::tag<ft::const_qualified,ft::volatile_qualified> >::type
  188. , T
  189. >));
  190. }
  191. struct C
  192. {
  193. void non_cv(int) { }
  194. void c_non_v(int) const { }
  195. void v_non_c(int) volatile { }
  196. void cv(int) const volatile { }
  197. };
  198. void instanitate()
  199. {
  200. test_non_cv(& C::non_cv);
  201. test_c_non_v(& C::c_non_v);
  202. test_v_non_c(& C::v_non_c);
  203. test_cv(& C::cv);
  204. }