placeholders.cpp 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. /*=============================================================================
  2. Copyright (c) 2017 Paul Fultz II
  3. placeholders.cpp
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. ==============================================================================*/
  7. #include <boost/hof/placeholders.hpp>
  8. #include "test.hpp"
  9. #include <sstream>
  10. // TODO: Test assign operators
  11. #if BOOST_HOF_HAS_STATIC_TEST_CHECK
  12. #define BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR constexpr
  13. #else
  14. #define BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR
  15. #endif
  16. struct square
  17. {
  18. template<class T>
  19. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto operator()(T x) const BOOST_HOF_RETURNS(x*x);
  20. };
  21. #define CHECK_DEFAULT_CONSTRUCTION_OP(op, name) \
  22. static_assert(boost::hof::detail::is_default_constructible<boost::hof::operators::name>::value, "Operator not default constructible");
  23. #if BOOST_HOF_HAS_NOEXCEPT_DEDUCTION
  24. #define PLACEHOLDER_CHECK(...) \
  25. BOOST_HOF_STATIC_TEST_CHECK(__VA_ARGS__); \
  26. BOOST_HOF_TEST_CHECK(__VA_ARGS__); \
  27. static_assert(noexcept(__VA_ARGS__), "noexcept placeholders")
  28. #else
  29. #define PLACEHOLDER_CHECK(...) \
  30. BOOST_HOF_STATIC_TEST_CHECK(__VA_ARGS__); \
  31. BOOST_HOF_TEST_CHECK(__VA_ARGS__)
  32. #endif
  33. BOOST_HOF_TEST_CASE()
  34. {
  35. static_assert(boost::hof::detail::is_default_constructible<boost::hof::placeholder<1>>::value, "Placeholder not default constructible");
  36. static_assert(boost::hof::detail::is_default_constructible<boost::hof::placeholder<2>>::value, "Placeholder not default constructible");
  37. static_assert(boost::hof::detail::is_default_constructible<boost::hof::placeholder<3>>::value, "Placeholder not default constructible");
  38. BOOST_HOF_FOREACH_BINARY_OP(CHECK_DEFAULT_CONSTRUCTION_OP)
  39. BOOST_HOF_FOREACH_ASSIGN_OP(CHECK_DEFAULT_CONSTRUCTION_OP)
  40. BOOST_HOF_FOREACH_UNARY_OP(CHECK_DEFAULT_CONSTRUCTION_OP)
  41. }
  42. BOOST_HOF_TEST_CASE()
  43. {
  44. auto simple_print = boost::hof::reveal(std::ref(std::cout) << boost::hof::_);
  45. simple_print("Hello");
  46. }
  47. BOOST_HOF_TEST_CASE()
  48. {
  49. std::stringstream ss;
  50. auto simple_print = boost::hof::reveal(std::ref(ss) << boost::hof::_);
  51. simple_print("Hello");
  52. BOOST_HOF_TEST_CHECK(ss.str() == "Hello");
  53. }
  54. BOOST_HOF_TEST_CASE()
  55. {
  56. const auto x_square_add = 2 + (4*4);
  57. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_square_add = boost::hof::_1 + boost::hof::lazy(square())(boost::hof::_2);
  58. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  59. static_assert(std::is_copy_constructible<decltype(f_square_add)>::value, "Not copyable");
  60. #endif
  61. PLACEHOLDER_CHECK(f_square_add(2, 4) == x_square_add);
  62. }
  63. BOOST_HOF_TEST_CASE()
  64. {
  65. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_invoke_2 = boost::hof::_1(3);
  66. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  67. static_assert(std::is_copy_constructible<decltype(f_invoke_2)>::value, "Not copyable");
  68. #endif
  69. PLACEHOLDER_CHECK(f_invoke_2(square()) == 9);
  70. }
  71. BOOST_HOF_TEST_CASE()
  72. {
  73. const auto x_add = 2 + 1;
  74. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_add = boost::hof::_1 + boost::hof::_2;
  75. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  76. static_assert(std::is_copy_constructible<decltype(f_add)>::value, "Not copyable");
  77. #endif
  78. static_assert(boost::hof::detail::is_default_constructible<decltype(f_add)>::value, "Not default constructible");
  79. PLACEHOLDER_CHECK(f_add(2, 1) == x_add);
  80. const auto x_subtract = 2 - 1;
  81. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_subtract = boost::hof::_1 - boost::hof::_2;
  82. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  83. static_assert(std::is_copy_constructible<decltype(f_subtract)>::value, "Not copyable");
  84. #endif
  85. static_assert(boost::hof::detail::is_default_constructible<decltype(f_subtract)>::value, "Not default constructible");
  86. PLACEHOLDER_CHECK(f_subtract(2, 1) == x_subtract);
  87. const auto x_multiply = 2 * 1;
  88. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_multiply = boost::hof::_1 * boost::hof::_2;
  89. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  90. static_assert(std::is_copy_constructible<decltype(f_multiply)>::value, "Not copyable");
  91. #endif
  92. static_assert(boost::hof::detail::is_default_constructible<decltype(f_multiply)>::value, "Not default constructible");
  93. PLACEHOLDER_CHECK(f_multiply(2, 1) == x_multiply);
  94. const auto x_divide = 2 / 1;
  95. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_divide = boost::hof::_1 / boost::hof::_2;
  96. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  97. static_assert(std::is_copy_constructible<decltype(f_divide)>::value, "Not copyable");
  98. #endif
  99. static_assert(boost::hof::detail::is_default_constructible<decltype(f_divide)>::value, "Not default constructible");
  100. PLACEHOLDER_CHECK(f_divide(2, 1) == x_divide);
  101. const auto x_remainder = 2 % 1;
  102. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_remainder = boost::hof::_1 % boost::hof::_2;
  103. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  104. static_assert(std::is_copy_constructible<decltype(f_remainder)>::value, "Not copyable");
  105. #endif
  106. static_assert(boost::hof::detail::is_default_constructible<decltype(f_remainder)>::value, "Not default constructible");
  107. PLACEHOLDER_CHECK(f_remainder(2, 1) == x_remainder);
  108. const auto x_shift_right = 2 >> 1;
  109. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_right = boost::hof::_1 >> boost::hof::_2;
  110. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  111. static_assert(std::is_copy_constructible<decltype(f_shift_right)>::value, "Not copyable");
  112. #endif
  113. static_assert(boost::hof::detail::is_default_constructible<decltype(f_shift_right)>::value, "Not default constructible");
  114. PLACEHOLDER_CHECK(f_shift_right(2, 1) == x_shift_right);
  115. const auto x_shift_left = 2 << 1;
  116. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_left = boost::hof::_1 << boost::hof::_2;
  117. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  118. static_assert(std::is_copy_constructible<decltype(f_shift_left)>::value, "Not copyable");
  119. #endif
  120. static_assert(boost::hof::detail::is_default_constructible<decltype(f_shift_left)>::value, "Not default constructible");
  121. PLACEHOLDER_CHECK(f_shift_left(2, 1) == x_shift_left);
  122. const auto x_greater_than = 2 > 1;
  123. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than = boost::hof::_1 > boost::hof::_2;
  124. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  125. static_assert(std::is_copy_constructible<decltype(f_greater_than)>::value, "Not copyable");
  126. #endif
  127. static_assert(boost::hof::detail::is_default_constructible<decltype(f_greater_than)>::value, "Not default constructible");
  128. PLACEHOLDER_CHECK(f_greater_than(2, 1) == x_greater_than);
  129. const auto x_less_than = 2 < 1;
  130. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than = boost::hof::_1 < boost::hof::_2;
  131. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  132. static_assert(std::is_copy_constructible<decltype(f_less_than)>::value, "Not copyable");
  133. #endif
  134. static_assert(boost::hof::detail::is_default_constructible<decltype(f_less_than)>::value, "Not default constructible");
  135. PLACEHOLDER_CHECK(f_less_than(2, 1) == x_less_than);
  136. const auto x_less_than_equal = 2 <= 1;
  137. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than_equal = boost::hof::_1 <= boost::hof::_2;
  138. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  139. static_assert(std::is_copy_constructible<decltype(f_less_than_equal)>::value, "Not copyable");
  140. #endif
  141. static_assert(boost::hof::detail::is_default_constructible<decltype(f_less_than_equal)>::value, "Not default constructible");
  142. PLACEHOLDER_CHECK(f_less_than_equal(2, 1) == x_less_than_equal);
  143. const auto x_greater_than_equal = 2 >= 1;
  144. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than_equal = boost::hof::_1 >= boost::hof::_2;
  145. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  146. static_assert(std::is_copy_constructible<decltype(f_greater_than_equal)>::value, "Not copyable");
  147. #endif
  148. static_assert(boost::hof::detail::is_default_constructible<decltype(f_greater_than_equal)>::value, "Not default constructible");
  149. PLACEHOLDER_CHECK(f_greater_than_equal(2, 1) == x_greater_than_equal);
  150. const auto x_equal = 2 == 1;
  151. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_equal = boost::hof::_1 == boost::hof::_2;
  152. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  153. static_assert(std::is_copy_constructible<decltype(f_equal)>::value, "Not copyable");
  154. #endif
  155. static_assert(boost::hof::detail::is_default_constructible<decltype(f_equal)>::value, "Not default constructible");
  156. PLACEHOLDER_CHECK(f_equal(2, 1) == x_equal);
  157. const auto x_not_equal = 2 != 1;
  158. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_equal = boost::hof::_1 != boost::hof::_2;
  159. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  160. static_assert(std::is_copy_constructible<decltype(f_not_equal)>::value, "Not copyable");
  161. #endif
  162. static_assert(boost::hof::detail::is_default_constructible<decltype(f_not_equal)>::value, "Not default constructible");
  163. PLACEHOLDER_CHECK(f_not_equal(2, 1) == x_not_equal);
  164. const auto x_bit_and = 2 & 1;
  165. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_and = boost::hof::_1 & boost::hof::_2;
  166. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  167. static_assert(std::is_copy_constructible<decltype(f_bit_and)>::value, "Not copyable");
  168. #endif
  169. static_assert(boost::hof::detail::is_default_constructible<decltype(f_bit_and)>::value, "Not default constructible");
  170. PLACEHOLDER_CHECK(f_bit_and(2, 1) == x_bit_and);
  171. const auto x_xor_ = 2 ^ 1;
  172. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_xor_ = boost::hof::_1 ^ boost::hof::_2;
  173. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  174. static_assert(std::is_copy_constructible<decltype(f_xor_)>::value, "Not copyable");
  175. #endif
  176. static_assert(boost::hof::detail::is_default_constructible<decltype(f_xor_)>::value, "Not default constructible");
  177. PLACEHOLDER_CHECK(f_xor_(2, 1) == x_xor_);
  178. const auto x_bit_or = 2 | 1;
  179. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_or = boost::hof::_1 | boost::hof::_2;
  180. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  181. static_assert(std::is_copy_constructible<decltype(f_bit_or)>::value, "Not copyable");
  182. #endif
  183. static_assert(boost::hof::detail::is_default_constructible<decltype(f_bit_or)>::value, "Not default constructible");
  184. PLACEHOLDER_CHECK(f_bit_or(2, 1) == x_bit_or);
  185. const auto x_and_ = true && false;
  186. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_and_ = boost::hof::_1 && boost::hof::_2;
  187. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  188. static_assert(std::is_copy_constructible<decltype(f_and_)>::value, "Not copyable");
  189. #endif
  190. static_assert(boost::hof::detail::is_default_constructible<decltype(f_and_)>::value, "Not default constructible");
  191. PLACEHOLDER_CHECK(f_and_(true, false) == x_and_);
  192. const auto x_or_ = true;
  193. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_or_ = boost::hof::_1 || boost::hof::_2;
  194. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  195. static_assert(std::is_copy_constructible<decltype(f_or_)>::value, "Not copyable");
  196. #endif
  197. static_assert(boost::hof::detail::is_default_constructible<decltype(f_or_)>::value, "Not default constructible");
  198. PLACEHOLDER_CHECK(f_or_(true, false) == x_or_);
  199. }
  200. BOOST_HOF_TEST_CASE()
  201. {
  202. const auto x_not_ = !false;
  203. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_ = !boost::hof::_1;
  204. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  205. static_assert(std::is_copy_constructible<decltype(f_not_)>::value, "Not copyable");
  206. #endif
  207. static_assert(boost::hof::detail::is_default_constructible<decltype(f_not_)>::value, "Not default constructible");
  208. PLACEHOLDER_CHECK(f_not_(false) == x_not_);
  209. const auto x_not_0 = !0;
  210. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_0 = !boost::hof::_1;
  211. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  212. static_assert(std::is_copy_constructible<decltype(f_not_0)>::value, "Not copyable");
  213. #endif
  214. static_assert(boost::hof::detail::is_default_constructible<decltype(f_not_0)>::value, "Not default constructible");
  215. PLACEHOLDER_CHECK(f_not_0(0) == x_not_0);
  216. const auto x_compl_ = ~2;
  217. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_compl_ = ~boost::hof::_1;
  218. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  219. static_assert(std::is_copy_constructible<decltype(f_compl_)>::value, "Not copyable");
  220. #endif
  221. static_assert(boost::hof::detail::is_default_constructible<decltype(f_compl_)>::value, "Not default constructible");
  222. PLACEHOLDER_CHECK(f_compl_(2) == x_compl_);
  223. const auto x_unary_plus = +2;
  224. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_unary_plus = +boost::hof::_1;
  225. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  226. static_assert(std::is_copy_constructible<decltype(f_unary_plus)>::value, "Not copyable");
  227. #endif
  228. static_assert(boost::hof::detail::is_default_constructible<decltype(f_unary_plus)>::value, "Not default constructible");
  229. PLACEHOLDER_CHECK(f_unary_plus(2) == x_unary_plus);
  230. const auto x_unary_subtract = -2;
  231. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_unary_subtract = -boost::hof::_1;
  232. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  233. static_assert(std::is_copy_constructible<decltype(f_unary_subtract)>::value, "Not copyable");
  234. #endif
  235. static_assert(boost::hof::detail::is_default_constructible<decltype(f_unary_subtract)>::value, "Not default constructible");
  236. PLACEHOLDER_CHECK(f_unary_subtract(2) == x_unary_subtract);
  237. const auto x_dereference = 2;
  238. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_dereference = *boost::hof::_1;
  239. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  240. static_assert(std::is_copy_constructible<decltype(f_dereference)>::value, "Not copyable");
  241. #endif
  242. static_assert(boost::hof::detail::is_default_constructible<decltype(f_dereference)>::value, "Not default constructible");
  243. PLACEHOLDER_CHECK(f_dereference(&x_dereference) == x_dereference);
  244. // TODO: Test BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR increment and decrement
  245. #ifndef _MSC_VER
  246. auto x_increment = 2;
  247. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_increment = ++boost::hof::_1;
  248. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  249. static_assert(std::is_copy_constructible<decltype(f_increment)>::value, "Not copyable");
  250. #endif
  251. static_assert(boost::hof::detail::is_default_constructible<decltype(f_increment)>::value, "Not default constructible");
  252. f_increment(x_increment);
  253. BOOST_HOF_TEST_CHECK(x_increment == 3);
  254. auto x_decrement = 2;
  255. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_decrement = --boost::hof::_1;
  256. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  257. static_assert(std::is_copy_constructible<decltype(f_decrement)>::value, "Not copyable");
  258. #endif
  259. static_assert(boost::hof::detail::is_default_constructible<decltype(f_decrement)>::value, "Not default constructible");
  260. f_decrement(x_decrement);
  261. BOOST_HOF_TEST_CHECK(x_decrement == 1);
  262. #endif
  263. // TODO: Test post increment and decrement
  264. }
  265. BOOST_HOF_TEST_CASE()
  266. {
  267. const auto x_add = 2 + 1;
  268. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_add = boost::hof::_ + boost::hof::_;
  269. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  270. static_assert(std::is_copy_constructible<decltype(f_add)>::value, "Not copyable");
  271. #endif
  272. static_assert(boost::hof::detail::is_default_constructible<decltype(f_add)>::value, "Not default constructible");
  273. PLACEHOLDER_CHECK(f_add(2, 1) == x_add);
  274. const auto x_subtract = 2 - 1;
  275. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_subtract = boost::hof::_ - boost::hof::_;
  276. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  277. static_assert(std::is_copy_constructible<decltype(f_subtract)>::value, "Not copyable");
  278. #endif
  279. static_assert(boost::hof::detail::is_default_constructible<decltype(f_subtract)>::value, "Not default constructible");
  280. PLACEHOLDER_CHECK(f_subtract(2, 1) == x_subtract);
  281. const auto x_multiply = 2 * 1;
  282. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_multiply = boost::hof::_ * boost::hof::_;
  283. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  284. static_assert(std::is_copy_constructible<decltype(f_multiply)>::value, "Not copyable");
  285. #endif
  286. static_assert(boost::hof::detail::is_default_constructible<decltype(f_multiply)>::value, "Not default constructible");
  287. PLACEHOLDER_CHECK(f_multiply(2, 1) == x_multiply);
  288. const auto x_divide = 2 / 1;
  289. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_divide = boost::hof::_ / boost::hof::_;
  290. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  291. static_assert(std::is_copy_constructible<decltype(f_divide)>::value, "Not copyable");
  292. #endif
  293. static_assert(boost::hof::detail::is_default_constructible<decltype(f_divide)>::value, "Not default constructible");
  294. PLACEHOLDER_CHECK(f_divide(2, 1) == x_divide);
  295. const auto x_remainder = 2 % 1;
  296. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_remainder = boost::hof::_ % boost::hof::_;
  297. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  298. static_assert(std::is_copy_constructible<decltype(f_remainder)>::value, "Not copyable");
  299. #endif
  300. static_assert(boost::hof::detail::is_default_constructible<decltype(f_remainder)>::value, "Not default constructible");
  301. PLACEHOLDER_CHECK(f_remainder(2, 1) == x_remainder);
  302. const auto x_shift_right = 2 >> 1;
  303. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_right = boost::hof::_ >> boost::hof::_;
  304. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  305. static_assert(std::is_copy_constructible<decltype(f_shift_right)>::value, "Not copyable");
  306. #endif
  307. static_assert(boost::hof::detail::is_default_constructible<decltype(f_shift_right)>::value, "Not default constructible");
  308. PLACEHOLDER_CHECK(f_shift_right(2, 1) == x_shift_right);
  309. const auto x_shift_left = 2 << 1;
  310. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_left = boost::hof::_ << boost::hof::_;
  311. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  312. static_assert(std::is_copy_constructible<decltype(f_shift_left)>::value, "Not copyable");
  313. #endif
  314. static_assert(boost::hof::detail::is_default_constructible<decltype(f_shift_left)>::value, "Not default constructible");
  315. PLACEHOLDER_CHECK(f_shift_left(2, 1) == x_shift_left);
  316. const auto x_greater_than = 2 > 1;
  317. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than = boost::hof::_ > boost::hof::_;
  318. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  319. static_assert(std::is_copy_constructible<decltype(f_greater_than)>::value, "Not copyable");
  320. #endif
  321. static_assert(boost::hof::detail::is_default_constructible<decltype(f_greater_than)>::value, "Not default constructible");
  322. PLACEHOLDER_CHECK(f_greater_than(2, 1) == x_greater_than);
  323. const auto x_less_than = 2 < 1;
  324. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than = boost::hof::_ < boost::hof::_;
  325. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  326. static_assert(std::is_copy_constructible<decltype(f_less_than)>::value, "Not copyable");
  327. #endif
  328. static_assert(boost::hof::detail::is_default_constructible<decltype(f_less_than)>::value, "Not default constructible");
  329. PLACEHOLDER_CHECK(f_less_than(2, 1) == x_less_than);
  330. const auto x_less_than_equal = 2 <= 1;
  331. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than_equal = boost::hof::_ <= boost::hof::_;
  332. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  333. static_assert(std::is_copy_constructible<decltype(f_less_than_equal)>::value, "Not copyable");
  334. #endif
  335. static_assert(boost::hof::detail::is_default_constructible<decltype(f_less_than_equal)>::value, "Not default constructible");
  336. PLACEHOLDER_CHECK(f_less_than_equal(2, 1) == x_less_than_equal);
  337. const auto x_greater_than_equal = 2 >= 1;
  338. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than_equal = boost::hof::_ >= boost::hof::_;
  339. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  340. static_assert(std::is_copy_constructible<decltype(f_greater_than_equal)>::value, "Not copyable");
  341. #endif
  342. static_assert(boost::hof::detail::is_default_constructible<decltype(f_greater_than_equal)>::value, "Not default constructible");
  343. PLACEHOLDER_CHECK(f_greater_than_equal(2, 1) == x_greater_than_equal);
  344. const auto x_equal = 2 == 1;
  345. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_equal = boost::hof::_ == boost::hof::_;
  346. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  347. static_assert(std::is_copy_constructible<decltype(f_equal)>::value, "Not copyable");
  348. #endif
  349. static_assert(boost::hof::detail::is_default_constructible<decltype(f_equal)>::value, "Not default constructible");
  350. PLACEHOLDER_CHECK(f_equal(2, 1) == x_equal);
  351. const auto x_not_equal = 2 != 1;
  352. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_equal = boost::hof::_ != boost::hof::_;
  353. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  354. static_assert(std::is_copy_constructible<decltype(f_not_equal)>::value, "Not copyable");
  355. #endif
  356. static_assert(boost::hof::detail::is_default_constructible<decltype(f_not_equal)>::value, "Not default constructible");
  357. PLACEHOLDER_CHECK(f_not_equal(2, 1) == x_not_equal);
  358. const auto x_bit_and = 2 & 1;
  359. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_and = boost::hof::_ & boost::hof::_;
  360. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  361. static_assert(std::is_copy_constructible<decltype(f_bit_and)>::value, "Not copyable");
  362. #endif
  363. static_assert(boost::hof::detail::is_default_constructible<decltype(f_bit_and)>::value, "Not default constructible");
  364. PLACEHOLDER_CHECK(f_bit_and(2, 1) == x_bit_and);
  365. const auto x_xor_ = 2 ^ 1;
  366. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_xor_ = boost::hof::_ ^ boost::hof::_;
  367. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  368. static_assert(std::is_copy_constructible<decltype(f_xor_)>::value, "Not copyable");
  369. #endif
  370. static_assert(boost::hof::detail::is_default_constructible<decltype(f_xor_)>::value, "Not default constructible");
  371. PLACEHOLDER_CHECK(f_xor_(2, 1) == x_xor_);
  372. const auto x_bit_or = 2 | 1;
  373. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_or = boost::hof::_ | boost::hof::_;
  374. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  375. static_assert(std::is_copy_constructible<decltype(f_bit_or)>::value, "Not copyable");
  376. #endif
  377. static_assert(boost::hof::detail::is_default_constructible<decltype(f_bit_or)>::value, "Not default constructible");
  378. PLACEHOLDER_CHECK(f_bit_or(2, 1) == x_bit_or);
  379. const auto x_and_ = true && false;
  380. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_and_ = boost::hof::_ && boost::hof::_;
  381. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  382. static_assert(std::is_copy_constructible<decltype(f_and_)>::value, "Not copyable");
  383. #endif
  384. static_assert(boost::hof::detail::is_default_constructible<decltype(f_and_)>::value, "Not default constructible");
  385. PLACEHOLDER_CHECK(f_and_(true, false) == x_and_);
  386. const auto x_or_ = true;
  387. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_or_ = boost::hof::_ || boost::hof::_;
  388. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  389. static_assert(std::is_copy_constructible<decltype(f_or_)>::value, "Not copyable");
  390. #endif
  391. static_assert(boost::hof::detail::is_default_constructible<decltype(f_or_)>::value, "Not default constructible");
  392. PLACEHOLDER_CHECK(f_or_(true, false) == x_or_);
  393. }
  394. BOOST_HOF_TEST_CASE()
  395. {
  396. const auto x_add = 2 + 1;
  397. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_add = 2 + boost::hof::_;
  398. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  399. static_assert(std::is_copy_constructible<decltype(f_add)>::value, "Not copyable");
  400. #endif
  401. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_add)>::value, "default constructible");
  402. PLACEHOLDER_CHECK(f_add(1) == x_add);
  403. const auto x_subtract = 2 - 1;
  404. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_subtract = 2 - boost::hof::_;
  405. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  406. static_assert(std::is_copy_constructible<decltype(f_subtract)>::value, "Not copyable");
  407. #endif
  408. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_subtract)>::value, "default constructible");
  409. PLACEHOLDER_CHECK(f_subtract(1) == x_subtract);
  410. const auto x_multiply = 2 * 1;
  411. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_multiply = 2 * boost::hof::_;
  412. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  413. static_assert(std::is_copy_constructible<decltype(f_multiply)>::value, "Not copyable");
  414. #endif
  415. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_multiply)>::value, "default constructible");
  416. PLACEHOLDER_CHECK(f_multiply(1) == x_multiply);
  417. const auto x_divide = 2 / 1;
  418. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_divide = 2 / boost::hof::_;
  419. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  420. static_assert(std::is_copy_constructible<decltype(f_divide)>::value, "Not copyable");
  421. #endif
  422. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_divide)>::value, "default constructible");
  423. PLACEHOLDER_CHECK(f_divide(1) == x_divide);
  424. const auto x_remainder = 2 % 1;
  425. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_remainder = 2 % boost::hof::_;
  426. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  427. static_assert(std::is_copy_constructible<decltype(f_remainder)>::value, "Not copyable");
  428. #endif
  429. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_remainder)>::value, "default constructible");
  430. PLACEHOLDER_CHECK(f_remainder(1) == x_remainder);
  431. const auto x_shift_right = 2 >> 1;
  432. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_right = 2 >> boost::hof::_;
  433. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  434. static_assert(std::is_copy_constructible<decltype(f_shift_right)>::value, "Not copyable");
  435. #endif
  436. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_shift_right)>::value, "default constructible");
  437. PLACEHOLDER_CHECK(f_shift_right(1) == x_shift_right);
  438. const auto x_shift_left = 2 << 1;
  439. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_left = 2 << boost::hof::_;
  440. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  441. static_assert(std::is_copy_constructible<decltype(f_shift_left)>::value, "Not copyable");
  442. #endif
  443. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_shift_left)>::value, "default constructible");
  444. PLACEHOLDER_CHECK(f_shift_left(1) == x_shift_left);
  445. const auto x_greater_than = 2 > 1;
  446. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than = 2 > boost::hof::_;
  447. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  448. static_assert(std::is_copy_constructible<decltype(f_greater_than)>::value, "Not copyable");
  449. #endif
  450. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_greater_than)>::value, "default constructible");
  451. PLACEHOLDER_CHECK(f_greater_than(1) == x_greater_than);
  452. const auto x_less_than = 2 < 1;
  453. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than = 2 < boost::hof::_;
  454. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  455. static_assert(std::is_copy_constructible<decltype(f_less_than)>::value, "Not copyable");
  456. #endif
  457. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_less_than)>::value, "default constructible");
  458. PLACEHOLDER_CHECK(f_less_than(1) == x_less_than);
  459. const auto x_less_than_equal = 2 <= 1;
  460. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than_equal = 2 <= boost::hof::_;
  461. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  462. static_assert(std::is_copy_constructible<decltype(f_less_than_equal)>::value, "Not copyable");
  463. #endif
  464. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_less_than_equal)>::value, "default constructible");
  465. PLACEHOLDER_CHECK(f_less_than_equal(1) == x_less_than_equal);
  466. const auto x_greater_than_equal = 2 >= 1;
  467. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than_equal = 2 >= boost::hof::_;
  468. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  469. static_assert(std::is_copy_constructible<decltype(f_greater_than_equal)>::value, "Not copyable");
  470. #endif
  471. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_greater_than_equal)>::value, "default constructible");
  472. PLACEHOLDER_CHECK(f_greater_than_equal(1) == x_greater_than_equal);
  473. const auto x_equal = 2 == 1;
  474. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_equal = 2 == boost::hof::_;
  475. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  476. static_assert(std::is_copy_constructible<decltype(f_equal)>::value, "Not copyable");
  477. #endif
  478. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_equal)>::value, "default constructible");
  479. PLACEHOLDER_CHECK(f_equal(1) == x_equal);
  480. const auto x_not_equal = 2 != 1;
  481. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_equal = 2 != boost::hof::_;
  482. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  483. static_assert(std::is_copy_constructible<decltype(f_not_equal)>::value, "Not copyable");
  484. #endif
  485. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_not_equal)>::value, "default constructible");
  486. PLACEHOLDER_CHECK(f_not_equal(1) == x_not_equal);
  487. const auto x_bit_and = 2 & 1;
  488. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_and = 2 & boost::hof::_;
  489. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  490. static_assert(std::is_copy_constructible<decltype(f_bit_and)>::value, "Not copyable");
  491. #endif
  492. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_bit_and)>::value, "default constructible");
  493. PLACEHOLDER_CHECK(f_bit_and(1) == x_bit_and);
  494. const auto x_xor_ = 2 ^ 1;
  495. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_xor_ = 2 ^ boost::hof::_;
  496. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  497. static_assert(std::is_copy_constructible<decltype(f_xor_)>::value, "Not copyable");
  498. #endif
  499. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_xor_)>::value, "default constructible");
  500. PLACEHOLDER_CHECK(f_xor_(1) == x_xor_);
  501. const auto x_bit_or = 2 | 1;
  502. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_or = 2 | boost::hof::_;
  503. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  504. static_assert(std::is_copy_constructible<decltype(f_bit_or)>::value, "Not copyable");
  505. #endif
  506. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_bit_or)>::value, "default constructible");
  507. PLACEHOLDER_CHECK(f_bit_or(1) == x_bit_or);
  508. const auto x_and_ = true && false;
  509. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_and_ = true && boost::hof::_;
  510. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  511. static_assert(std::is_copy_constructible<decltype(f_and_)>::value, "Not copyable");
  512. #endif
  513. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_and_)>::value, "default constructible");
  514. PLACEHOLDER_CHECK(f_and_(false) == x_and_);
  515. const auto x_or_ = true;
  516. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_or_ = true || boost::hof::_;
  517. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  518. static_assert(std::is_copy_constructible<decltype(f_or_)>::value, "Not copyable");
  519. #endif
  520. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_or_)>::value, "default constructible");
  521. PLACEHOLDER_CHECK(f_or_(false) == x_or_);
  522. }
  523. BOOST_HOF_TEST_CASE()
  524. {
  525. const auto x_add = 2 + 1;
  526. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_add = boost::hof::_ + 1;
  527. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  528. static_assert(std::is_copy_constructible<decltype(f_add)>::value, "Not copyable");
  529. #endif
  530. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_add)>::value, "default constructible");
  531. PLACEHOLDER_CHECK(f_add(2) == x_add);
  532. const auto x_subtract = 2 - 1;
  533. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_subtract = boost::hof::_ - 1;
  534. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  535. static_assert(std::is_copy_constructible<decltype(f_subtract)>::value, "Not copyable");
  536. #endif
  537. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_subtract)>::value, "default constructible");
  538. PLACEHOLDER_CHECK(f_subtract(2) == x_subtract);
  539. const auto x_multiply = 2 * 1;
  540. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_multiply = boost::hof::_ * 1;
  541. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  542. static_assert(std::is_copy_constructible<decltype(f_multiply)>::value, "Not copyable");
  543. #endif
  544. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_multiply)>::value, "default constructible");
  545. PLACEHOLDER_CHECK(f_multiply(2) == x_multiply);
  546. const auto x_divide = 2 / 1;
  547. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_divide = boost::hof::_ / 1;
  548. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  549. static_assert(std::is_copy_constructible<decltype(f_divide)>::value, "Not copyable");
  550. #endif
  551. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_divide)>::value, "default constructible");
  552. PLACEHOLDER_CHECK(f_divide(2) == x_divide);
  553. const auto x_remainder = 2 % 1;
  554. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_remainder = boost::hof::_ % 1;
  555. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  556. static_assert(std::is_copy_constructible<decltype(f_remainder)>::value, "Not copyable");
  557. #endif
  558. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_remainder)>::value, "default constructible");
  559. PLACEHOLDER_CHECK(f_remainder(2) == x_remainder);
  560. const auto x_shift_right = 2 >> 1;
  561. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_right = boost::hof::_ >> 1;
  562. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  563. static_assert(std::is_copy_constructible<decltype(f_shift_right)>::value, "Not copyable");
  564. #endif
  565. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_shift_right)>::value, "default constructible");
  566. PLACEHOLDER_CHECK(f_shift_right(2) == x_shift_right);
  567. const auto x_shift_left = 2 << 1;
  568. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_shift_left = boost::hof::_ << 1;
  569. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  570. static_assert(std::is_copy_constructible<decltype(f_shift_left)>::value, "Not copyable");
  571. #endif
  572. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_shift_left)>::value, "default constructible");
  573. PLACEHOLDER_CHECK(f_shift_left(2) == x_shift_left);
  574. const auto x_greater_than = 2 > 1;
  575. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than = boost::hof::_ > 1;
  576. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  577. static_assert(std::is_copy_constructible<decltype(f_greater_than)>::value, "Not copyable");
  578. #endif
  579. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_greater_than)>::value, "default constructible");
  580. PLACEHOLDER_CHECK(f_greater_than(2) == x_greater_than);
  581. const auto x_less_than = 2 < 1;
  582. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than = boost::hof::_ < 1;
  583. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  584. static_assert(std::is_copy_constructible<decltype(f_less_than)>::value, "Not copyable");
  585. #endif
  586. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_less_than)>::value, "default constructible");
  587. PLACEHOLDER_CHECK(f_less_than(2) == x_less_than);
  588. const auto x_less_than_equal = 2 <= 1;
  589. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_less_than_equal = boost::hof::_ <= 1;
  590. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  591. static_assert(std::is_copy_constructible<decltype(f_less_than_equal)>::value, "Not copyable");
  592. #endif
  593. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_less_than_equal)>::value, "default constructible");
  594. PLACEHOLDER_CHECK(f_less_than_equal(2) == x_less_than_equal);
  595. const auto x_greater_than_equal = 2 >= 1;
  596. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_greater_than_equal = boost::hof::_ >= 1;
  597. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  598. static_assert(std::is_copy_constructible<decltype(f_greater_than_equal)>::value, "Not copyable");
  599. #endif
  600. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_greater_than_equal)>::value, "default constructible");
  601. PLACEHOLDER_CHECK(f_greater_than_equal(2) == x_greater_than_equal);
  602. const auto x_equal = 2 == 1;
  603. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_equal = boost::hof::_ == 1;
  604. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  605. static_assert(std::is_copy_constructible<decltype(f_equal)>::value, "Not copyable");
  606. #endif
  607. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_equal)>::value, "default constructible");
  608. PLACEHOLDER_CHECK(f_equal(2) == x_equal);
  609. const auto x_not_equal = 2 != 1;
  610. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_equal = boost::hof::_ != 1;
  611. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  612. static_assert(std::is_copy_constructible<decltype(f_not_equal)>::value, "Not copyable");
  613. #endif
  614. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_not_equal)>::value, "default constructible");
  615. PLACEHOLDER_CHECK(f_not_equal(2) == x_not_equal);
  616. const auto x_bit_and = 2 & 1;
  617. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_and = boost::hof::_ & 1;
  618. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  619. static_assert(std::is_copy_constructible<decltype(f_bit_and)>::value, "Not copyable");
  620. #endif
  621. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_bit_and)>::value, "default constructible");
  622. PLACEHOLDER_CHECK(f_bit_and(2) == x_bit_and);
  623. const auto x_xor_ = 2 ^ 1;
  624. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_xor_ = boost::hof::_ ^ 1;
  625. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  626. static_assert(std::is_copy_constructible<decltype(f_xor_)>::value, "Not copyable");
  627. #endif
  628. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_xor_)>::value, "default constructible");
  629. PLACEHOLDER_CHECK(f_xor_(2) == x_xor_);
  630. const auto x_bit_or = 2 | 1;
  631. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_bit_or = boost::hof::_ | 1;
  632. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  633. static_assert(std::is_copy_constructible<decltype(f_bit_or)>::value, "Not copyable");
  634. #endif
  635. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_bit_or)>::value, "default constructible");
  636. PLACEHOLDER_CHECK(f_bit_or(2) == x_bit_or);
  637. const auto x_and_ = true && false;
  638. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_and_ = boost::hof::_ && false;
  639. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  640. static_assert(std::is_copy_constructible<decltype(f_and_)>::value, "Not copyable");
  641. #endif
  642. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_and_)>::value, "default constructible");
  643. PLACEHOLDER_CHECK(f_and_(true) == x_and_);
  644. const auto x_or_ = true;
  645. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_or_ = boost::hof::_ || false;
  646. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  647. static_assert(std::is_copy_constructible<decltype(f_or_)>::value, "Not copyable");
  648. #endif
  649. static_assert(!boost::hof::detail::is_default_constructible<decltype(f_or_)>::value, "default constructible");
  650. PLACEHOLDER_CHECK(f_or_(true) == x_or_);
  651. }
  652. BOOST_HOF_TEST_CASE()
  653. {
  654. const auto x_not_ = !false;
  655. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_not_ = !boost::hof::_;
  656. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  657. static_assert(std::is_copy_constructible<decltype(f_not_)>::value, "Not copyable");
  658. #endif
  659. static_assert(boost::hof::detail::is_default_constructible<decltype(f_not_)>::value, "Not default constructible");
  660. PLACEHOLDER_CHECK(f_not_(false) == x_not_);
  661. const auto x_compl_ = ~2;
  662. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_compl_ = ~boost::hof::_;
  663. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  664. static_assert(std::is_copy_constructible<decltype(f_compl_)>::value, "Not copyable");
  665. #endif
  666. static_assert(boost::hof::detail::is_default_constructible<decltype(f_compl_)>::value, "Not default constructible");
  667. PLACEHOLDER_CHECK(f_compl_(2) == x_compl_);
  668. const auto x_unary_plus = +2;
  669. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_unary_plus = +boost::hof::_;
  670. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  671. static_assert(std::is_copy_constructible<decltype(f_unary_plus)>::value, "Not copyable");
  672. #endif
  673. static_assert(boost::hof::detail::is_default_constructible<decltype(f_unary_plus)>::value, "Not default constructible");
  674. PLACEHOLDER_CHECK(f_unary_plus(2) == x_unary_plus);
  675. const auto x_unary_subtract = -2;
  676. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_unary_subtract = -boost::hof::_;
  677. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  678. static_assert(std::is_copy_constructible<decltype(f_unary_subtract)>::value, "Not copyable");
  679. #endif
  680. static_assert(boost::hof::detail::is_default_constructible<decltype(f_unary_subtract)>::value, "Not default constructible");
  681. PLACEHOLDER_CHECK(f_unary_subtract(2) == x_unary_subtract);
  682. const auto x_dereference = 2;
  683. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_dereference = *boost::hof::_;
  684. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  685. static_assert(std::is_copy_constructible<decltype(f_dereference)>::value, "Not copyable");
  686. #endif
  687. static_assert(boost::hof::detail::is_default_constructible<decltype(f_dereference)>::value, "Not default constructible");
  688. PLACEHOLDER_CHECK(f_dereference(&x_dereference) == x_dereference);
  689. // TODO: Test constexpr increment and decrement
  690. #ifndef _MSC_VER
  691. auto x_increment = 2;
  692. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_increment = ++boost::hof::_;
  693. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  694. static_assert(std::is_copy_constructible<decltype(f_increment)>::value, "Not copyable");
  695. #endif
  696. static_assert(boost::hof::detail::is_default_constructible<decltype(f_increment)>::value, "Not default constructible");
  697. f_increment(x_increment);
  698. BOOST_HOF_TEST_CHECK(x_increment == 3);
  699. auto x_decrement = 2;
  700. BOOST_HOF_PLACEHOLDER_TEST_CONSTEXPR auto f_decrement = --boost::hof::_;
  701. #if defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ > 6
  702. static_assert(std::is_copy_constructible<decltype(f_decrement)>::value, "Not copyable");
  703. #endif
  704. static_assert(boost::hof::detail::is_default_constructible<decltype(f_decrement)>::value, "Not default constructible");
  705. f_decrement(x_decrement);
  706. BOOST_HOF_TEST_CHECK(x_decrement == 1);
  707. #endif
  708. // TODO: Test post increment and decrement
  709. }