preprocessor_eval_cat_8.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. // Copyright Cromwell D. Enage 2017.
  2. // Distributed under the Boost Software License, Version 1.0.
  3. // (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/parameter/config.hpp>
  6. #if ( \
  7. !defined(__MINGW32__) && \
  8. defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) \
  9. ) || defined(BOOST_MSVC)
  10. #if (BOOST_PARAMETER_MAX_ARITY < 8)
  11. #error Define BOOST_PARAMETER_MAX_ARITY as 8 or greater.
  12. #endif
  13. #else // mingw, or no perfect forwarding support and not msvc
  14. #if (BOOST_PARAMETER_COMPOSE_MAX_ARITY < 8)
  15. #error Define BOOST_PARAMETER_COMPOSE_MAX_ARITY as 8 or greater.
  16. #endif
  17. #endif // msvc, or perfect forwarding support and not mingw
  18. #include <boost/parameter/name.hpp>
  19. namespace test {
  20. BOOST_PARAMETER_NAME((_lrc0, kw) in(lrc0))
  21. BOOST_PARAMETER_NAME((_lr0, kw) in_out(lr0))
  22. BOOST_PARAMETER_NAME((_rrc0, kw) in(rrc0))
  23. #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  24. BOOST_PARAMETER_NAME((_rr0, kw) consume(rr0))
  25. #else
  26. BOOST_PARAMETER_NAME((_rr0, kw) rr0)
  27. #endif
  28. BOOST_PARAMETER_NAME((_lrc1, kw) in(lrc1))
  29. BOOST_PARAMETER_NAME((_lr1, kw) out(lr1))
  30. BOOST_PARAMETER_NAME((_rrc1, kw) in(rrc1))
  31. BOOST_PARAMETER_NAME((_rr1, kw) rr1)
  32. } // namespace test
  33. #include <boost/mpl/bool.hpp>
  34. #include <boost/mpl/placeholders.hpp>
  35. #include <boost/mpl/if.hpp>
  36. #include <boost/core/lightweight_test.hpp>
  37. #include <boost/type_traits/is_convertible.hpp>
  38. #include "evaluate_category.hpp"
  39. #if !defined(__MINGW32__) && defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  40. #include <boost/parameter/preprocessor.hpp>
  41. #include <utility>
  42. #elif defined(BOOST_MSVC)
  43. #include <boost/parameter/preprocessor.hpp>
  44. #else
  45. #include <boost/parameter/preprocessor_no_spec.hpp>
  46. #endif
  47. namespace test {
  48. struct C
  49. {
  50. #if ( \
  51. !defined(__MINGW32__) && \
  52. defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) \
  53. ) || defined(BOOST_MSVC)
  54. typedef boost::mpl::if_<
  55. boost::is_convertible<boost::mpl::_,std::bitset<1> >
  56. , boost::mpl::true_
  57. , boost::mpl::false_
  58. > bs0_pred;
  59. typedef boost::mpl::if_<
  60. boost::is_convertible<boost::mpl::_,std::bitset<2> >
  61. , boost::mpl::true_
  62. , boost::mpl::false_
  63. > bs1_pred;
  64. typedef boost::mpl::if_<
  65. boost::is_convertible<boost::mpl::_,std::bitset<3> >
  66. , boost::mpl::true_
  67. , boost::mpl::false_
  68. > bs2_pred;
  69. typedef boost::mpl::if_<
  70. boost::is_convertible<boost::mpl::_,std::bitset<4> >
  71. , boost::mpl::true_
  72. , boost::mpl::false_
  73. > bs3_pred;
  74. typedef boost::mpl::if_<
  75. boost::is_convertible<boost::mpl::_,std::bitset<5> >
  76. , boost::mpl::true_
  77. , boost::mpl::false_
  78. > bs4_pred;
  79. typedef boost::mpl::if_<
  80. boost::is_convertible<boost::mpl::_,std::bitset<6> >
  81. , boost::mpl::true_
  82. , boost::mpl::false_
  83. > bs5_pred;
  84. typedef boost::mpl::if_<
  85. boost::is_convertible<boost::mpl::_,std::bitset<7> >
  86. , boost::mpl::true_
  87. , boost::mpl::false_
  88. > bs6_pred;
  89. typedef boost::mpl::if_<
  90. boost::is_convertible<boost::mpl::_,std::bitset<8> >
  91. , boost::mpl::true_
  92. , boost::mpl::false_
  93. > bs7_pred;
  94. BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR((bool), kw,
  95. (deduced
  96. (required
  97. (lrc0, *(bs0_pred))
  98. (lr0, *(bs1_pred))
  99. (rrc0, *(bs2_pred))
  100. (rr0, *(bs3_pred))
  101. (lrc1, *(bs4_pred))
  102. )
  103. (optional
  104. (lr1, *(bs5_pred), test::lvalue_bitset<5>())
  105. (rrc1, *(bs6_pred), test::rvalue_const_bitset<6>())
  106. (rr1, *(bs7_pred), test::rvalue_bitset<7>())
  107. )
  108. )
  109. )
  110. #else
  111. BOOST_PARAMETER_NO_SPEC_CONST_FUNCTION_CALL_OPERATOR((bool))
  112. #endif // msvc, or perfect forwarding support and not mingw
  113. {
  114. #if ( \
  115. !defined(__MINGW32__) && \
  116. defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) \
  117. ) || defined(BOOST_MSVC)
  118. BOOST_TEST_EQ(
  119. test::passed_by_lvalue_reference_to_const
  120. , test::U::evaluate_category<0>(lrc0)
  121. );
  122. BOOST_TEST_EQ(
  123. test::passed_by_lvalue_reference
  124. , test::U::evaluate_category<1>(lr0)
  125. );
  126. BOOST_TEST_EQ(
  127. test::passed_by_lvalue_reference_to_const
  128. , test::U::evaluate_category<4>(lrc1)
  129. );
  130. BOOST_TEST_EQ(
  131. test::passed_by_lvalue_reference
  132. , test::U::evaluate_category<5>(lr1)
  133. );
  134. #else // mingw, or no perfect forwarding support and not msvc
  135. BOOST_TEST_EQ(
  136. test::passed_by_lvalue_reference_to_const
  137. , test::U::evaluate_category<0>(args[test::_lrc0])
  138. );
  139. BOOST_TEST_EQ(
  140. test::passed_by_lvalue_reference
  141. , test::U::evaluate_category<1>(args[test::_lr0])
  142. );
  143. BOOST_TEST_EQ(
  144. test::passed_by_lvalue_reference_to_const
  145. , test::U::evaluate_category<4>(args[test::_lrc1])
  146. );
  147. BOOST_TEST_EQ(
  148. test::passed_by_lvalue_reference
  149. , test::U::evaluate_category<5>(
  150. args[test::_lr1 | test::lvalue_bitset<5>()]
  151. )
  152. );
  153. #endif // msvc, or perfect forwarding support and not mingw
  154. #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  155. #if defined(__MINGW32__)
  156. BOOST_TEST_EQ(
  157. test::passed_by_rvalue_reference_to_const
  158. , test::U::evaluate_category<2>(args[test::_rrc0])
  159. );
  160. BOOST_TEST_EQ(
  161. test::passed_by_rvalue_reference
  162. , test::U::evaluate_category<3>(args[test::_rr0])
  163. );
  164. BOOST_TEST_EQ(
  165. test::passed_by_rvalue_reference_to_const
  166. , test::U::evaluate_category<6>(
  167. args[test::_rrc1 | test::rvalue_const_bitset<6>()]
  168. )
  169. );
  170. BOOST_TEST_EQ(
  171. test::passed_by_rvalue_reference
  172. , test::U::evaluate_category<7>(
  173. args[test::_rr1 | test::rvalue_bitset<7>()]
  174. )
  175. );
  176. #else // !defined(__MINGW32__)
  177. BOOST_TEST_EQ(
  178. test::passed_by_rvalue_reference_to_const
  179. , test::U::evaluate_category<2>(std::forward<rrc0_type>(rrc0))
  180. );
  181. BOOST_TEST_EQ(
  182. test::passed_by_rvalue_reference
  183. , test::U::evaluate_category<3>(std::forward<rr0_type>(rr0))
  184. );
  185. BOOST_TEST_EQ(
  186. test::passed_by_rvalue_reference_to_const
  187. , test::U::evaluate_category<6>(std::forward<rrc1_type>(rrc1))
  188. );
  189. BOOST_TEST_EQ(
  190. test::passed_by_rvalue_reference
  191. , test::U::evaluate_category<7>(std::forward<rr1_type>(rr1))
  192. );
  193. #endif // __MINGW32__
  194. #else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING)
  195. #if defined(BOOST_MSVC)
  196. BOOST_TEST_EQ(
  197. test::passed_by_lvalue_reference_to_const
  198. , test::U::evaluate_category<2>(rrc0)
  199. );
  200. BOOST_TEST_EQ(
  201. test::passed_by_lvalue_reference_to_const
  202. , test::U::evaluate_category<3>(rr0)
  203. );
  204. BOOST_TEST_EQ(
  205. test::passed_by_lvalue_reference_to_const
  206. , test::U::evaluate_category<6>(rrc1)
  207. );
  208. BOOST_TEST_EQ(
  209. test::passed_by_lvalue_reference_to_const
  210. , test::U::evaluate_category<7>(rr1)
  211. );
  212. #else // !defined(BOOST_MSVC)
  213. BOOST_TEST_EQ(
  214. test::passed_by_lvalue_reference_to_const
  215. , test::U::evaluate_category<2>(args[test::_rrc0])
  216. );
  217. BOOST_TEST_EQ(
  218. test::passed_by_lvalue_reference_to_const
  219. , test::U::evaluate_category<3>(args[test::_rr0])
  220. );
  221. BOOST_TEST_EQ(
  222. test::passed_by_lvalue_reference_to_const
  223. , test::U::evaluate_category<6>(
  224. args[test::_rrc1 | test::rvalue_const_bitset<6>()]
  225. )
  226. );
  227. BOOST_TEST_EQ(
  228. test::passed_by_lvalue_reference_to_const
  229. , test::U::evaluate_category<7>(
  230. args[test::_rr1 | test::rvalue_bitset<7>()]
  231. )
  232. );
  233. #endif // BOOST_MSVC
  234. #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING
  235. return true;
  236. }
  237. };
  238. } // namespace test
  239. int main()
  240. {
  241. test::C cp0;
  242. test::C cp1;
  243. #if ( \
  244. !defined(__MINGW32__) && \
  245. defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) \
  246. ) || defined(BOOST_MSVC)
  247. cp0(
  248. test::lvalue_const_bitset<4>()
  249. , test::lvalue_const_bitset<0>()
  250. , test::lvalue_bitset<1>()
  251. , test::rvalue_const_bitset<2>()
  252. , test::rvalue_bitset<3>()
  253. );
  254. cp0(
  255. test::lvalue_const_bitset<4>()
  256. , test::lvalue_const_bitset<0>()
  257. , test::rvalue_const_bitset<6>()
  258. , test::lvalue_bitset<1>()
  259. , test::rvalue_const_bitset<2>()
  260. , test::rvalue_bitset<3>()
  261. );
  262. cp1(
  263. test::lvalue_bitset<1>()
  264. , test::rvalue_const_bitset<2>()
  265. , test::rvalue_bitset<3>()
  266. , test::lvalue_const_bitset<4>()
  267. , test::lvalue_bitset<5>()
  268. , test::rvalue_const_bitset<6>()
  269. , test::rvalue_bitset<7>()
  270. , test::lvalue_const_bitset<0>()
  271. );
  272. #else // mingw, or no perfect forwarding support and not msvc
  273. cp0(
  274. test::_lrc1 = test::lvalue_const_bitset<4>()
  275. , test::_lrc0 = test::lvalue_const_bitset<0>()
  276. , test::_lr0 = test::lvalue_bitset<1>()
  277. , test::_rrc0 = test::rvalue_const_bitset<2>()
  278. , test::_rr0 = test::rvalue_bitset<3>()
  279. );
  280. cp0(
  281. test::_lrc1 = test::lvalue_const_bitset<4>()
  282. , test::_lrc0 = test::lvalue_const_bitset<0>()
  283. , test::_rrc1 = test::rvalue_const_bitset<6>()
  284. , test::_lr0 = test::lvalue_bitset<1>()
  285. , test::_rrc0 = test::rvalue_const_bitset<2>()
  286. , test::_rr0 = test::rvalue_bitset<3>()
  287. );
  288. cp1(
  289. test::_lr0 = test::lvalue_bitset<1>()
  290. , test::_rrc0 = test::rvalue_const_bitset<2>()
  291. , test::_rr0 = test::rvalue_bitset<3>()
  292. , test::_lrc1 = test::lvalue_const_bitset<4>()
  293. , test::_lr1 = test::lvalue_bitset<5>()
  294. , test::_rrc1 = test::rvalue_const_bitset<6>()
  295. , test::_rr1 = test::rvalue_bitset<7>()
  296. , test::_lrc0 = test::lvalue_const_bitset<0>()
  297. );
  298. #endif // msvc, or perfect forwarding support and not mingw
  299. return boost::report_errors();
  300. }