| 1 | // Copyright Louis Dionne 2013-2022 |
| 2 | // Distributed under the Boost Software License, Version 1.0. |
| 3 | // (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) |
| 4 | |
| 5 | #include <boost/hana/assert.hpp> |
| 6 | #include <boost/hana/detail/struct_macros.hpp> |
| 7 | |
| 8 | #include <string> |
| 9 | #include <vector> |
| 10 | |
| 11 | |
| 12 | ////////////////////////////////////////////////////////////////////////////// |
| 13 | // BOOST_HANA_PP_NARG |
| 14 | ////////////////////////////////////////////////////////////////////////////// |
| 15 | static_assert(BOOST_HANA_PP_NARG(x) == 1, "" ); |
| 16 | static_assert(BOOST_HANA_PP_NARG(x, x) == 2, "" ); |
| 17 | static_assert(BOOST_HANA_PP_NARG(x, x, x) == 3, "" ); |
| 18 | static_assert(BOOST_HANA_PP_NARG(x, x, x, x) == 4, "" ); |
| 19 | static_assert(BOOST_HANA_PP_NARG( |
| 20 | x, x, x, x, x, x, x, x, x, x, |
| 21 | x, x, x, x, x, x, x, x, x, x, |
| 22 | x, x, x, x, x, x, x, x, x, x, |
| 23 | x, x, x, x, x, x, x, x) == 38, "" ); |
| 24 | static_assert(BOOST_HANA_PP_NARG( |
| 25 | x, x, x, x, x, x, x, x, x, x, |
| 26 | x, x, x, x, x, x, x, x, x, x, |
| 27 | x, x, x, x, x, x, x, x, x, x, |
| 28 | x, x, x, x, x, x, x, x, x) == 39, "" ); |
| 29 | static_assert(BOOST_HANA_PP_NARG( |
| 30 | x, x, x, x, x, x, x, x, x, x, |
| 31 | x, x, x, x, x, x, x, x, x, x, |
| 32 | x, x, x, x, x, x, x, x, x, x, |
| 33 | x, x, x, x, x, x, x, x, x, x) == 40, "" ); |
| 34 | |
| 35 | |
| 36 | ////////////////////////////////////////////////////////////////////////////// |
| 37 | // BOOST_HANA_PP_BACK |
| 38 | ////////////////////////////////////////////////////////////////////////////// |
| 39 | static_assert(BOOST_HANA_PP_BACK(1) == 1, "" ); |
| 40 | static_assert(BOOST_HANA_PP_BACK(1, 2) == 2, "" ); |
| 41 | static_assert(BOOST_HANA_PP_BACK(1, 2, 3) == 3, "" ); |
| 42 | static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4) == 4, "" ); |
| 43 | |
| 44 | static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 45 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 46 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 47 | 31, 32, 33, 34, 35, 36, 37, 38, 39) == 39, "" ); |
| 48 | |
| 49 | static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 50 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 51 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 52 | 31, 32, 33, 34, 35, 36, 37, 38) == 38, "" ); |
| 53 | |
| 54 | static_assert(BOOST_HANA_PP_BACK(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 55 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 56 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 57 | 31, 32, 33, 34, 35, 36, 37, 38, 39, 40) == 40, "" ); |
| 58 | |
| 59 | |
| 60 | int main() { |
| 61 | using Vector = std::vector<int>; |
| 62 | |
| 63 | ////////////////////////////////////////////////////////////////////////// |
| 64 | // BOOST_HANA_PP_DROP_BACK |
| 65 | ////////////////////////////////////////////////////////////////////////// |
| 66 | { |
| 67 | Vector args = {BOOST_HANA_PP_DROP_BACK(1)}; |
| 68 | BOOST_HANA_RUNTIME_CHECK(args.empty()); |
| 69 | }{ |
| 70 | Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2)}; |
| 71 | BOOST_HANA_RUNTIME_CHECK(args == Vector{1}); |
| 72 | }{ |
| 73 | Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2, 3)}; |
| 74 | BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2}); |
| 75 | }{ |
| 76 | Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2, 3, 4)}; |
| 77 | BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2, 3}); |
| 78 | }{ |
| 79 | Vector args = {BOOST_HANA_PP_DROP_BACK(1, 2, 3, 4, 5)}; |
| 80 | BOOST_HANA_RUNTIME_CHECK(args == Vector{1, 2, 3, 4}); |
| 81 | }{ |
| 82 | Vector args = {BOOST_HANA_PP_DROP_BACK( |
| 83 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 84 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 85 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 86 | 31, 32, 33, 34, 35, 36, 37, 38, 39 |
| 87 | )}; |
| 88 | BOOST_HANA_RUNTIME_CHECK(args == Vector{ |
| 89 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 90 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 91 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 92 | 31, 32, 33, 34, 35, 36, 37, 38 |
| 93 | }); |
| 94 | }{ |
| 95 | Vector args = {BOOST_HANA_PP_DROP_BACK( |
| 96 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 97 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 98 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 99 | 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 |
| 100 | )}; |
| 101 | BOOST_HANA_RUNTIME_CHECK(args == Vector{ |
| 102 | 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, |
| 103 | 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, |
| 104 | 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, |
| 105 | 31, 32, 33, 34, 35, 36, 37, 38, 39 |
| 106 | }); |
| 107 | } |
| 108 | } |
| 109 | |