| 33 | struct storage { char weight[n]; }; |
| 34 | |
| 35 | int main() { |
| 36 | |
| 37 | { |
| 38 | |
| 39 | //! [tuple] |
| 40 | auto types = hana::make_tuple(hana::type_c<int*>, hana::type_c<char&>, hana::type_c<void>); |
| 41 | auto char_ref = types[1_c]; |
| 42 | |
| 43 | BOOST_HANA_CONSTANT_CHECK(char_ref == hana::type_c<char&>); |
| 44 | //! [tuple] |
| 45 | |
| 46 | }{ |
| 47 | |
| 48 | //! [filter.MPL] |
| 49 | using types = mpl::vector<int, char&, void*>; |
| 50 | using ts = mpl::copy_if<types, mpl::or_<std::is_pointer<mpl::_1>, |
| 51 | std::is_reference<mpl::_1>>>::type; |
| 52 | // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 53 | // placeholder expression |
| 54 | |
| 55 | static_assert(mpl::equal<ts, mpl::vector<char&, void*>>::value, ""); |
| 56 | //! [filter.MPL] |
| 57 | |
| 58 | }{ |
| 59 | |
| 60 | using hana::traits::is_pointer; // the traits namespace was not introduced |
| 61 | using hana::traits::is_reference; // yet, so we use unqualified names for now |
| 62 | |
| 63 | //! [filter.Hana] |
| 64 | auto types = hana::tuple_t<int*, char&, void>; |
| 65 | |
| 66 | auto ts = hana::filter(types, [](auto t) { |
| 67 | return is_pointer(t) || is_reference(t); |
| 68 | }); |
| 69 | |
| 70 | BOOST_HANA_CONSTANT_CHECK(ts == hana::tuple_t<int*, char&>); |
| 71 | //! [filter.Hana] |
| 72 | |
| 73 | }{ |
| 74 | |
| 75 | //! [single_library.then] |
| 76 | // types (MPL) |
| 77 | using types = mpl::vector<int*, char&, void>; |
| 78 | using ts = mpl::copy_if<types, mpl::or_<std::is_pointer<mpl::_1>, |
| 79 | std::is_reference<mpl::_1>>>::type; |
| 80 | |
| 81 | // values (Fusion) |
| 82 | auto values = fusion::make_vector(1, 'c', nullptr, 3.5); |
| 83 | auto vs = fusion::filter_if<std::is_integral<mpl::_1>>(values); |
| 84 | //! [single_library.then] |
| 85 | |
| 86 | static_assert(mpl::equal<ts, mpl::vector<int*, char&>>::value, ""); |
| 87 | BOOST_HANA_RUNTIME_CHECK(vs == fusion::make_vector(1, 'c')); |
| 88 | |
| 89 | }{ |
| 90 | |
| 91 | using hana::traits::is_pointer; |
| 92 | using hana::traits::is_reference; |
nothing calls this directly
no test coverage detected