/* @copyright Louis Dionne 2015 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #include #include #include #include #include #include #include #include using namespace boost::hana; int main() { { //! [concat] using namespace literals; BOOST_HANA_CONSTEXPR_CHECK( concat(make(1, '2'), make(3.3, 4_c)) == make(1, '2', 3.3, 4_c) ); //! [concat] }{ //! [empty] BOOST_HANA_CONSTANT_CHECK(empty() == make()); BOOST_HANA_CONSTANT_CHECK(empty() == nothing); //! [empty] }{ //! [prepend] BOOST_HANA_CONSTEXPR_CHECK(prepend(1, make()) == make(1)); BOOST_HANA_CONSTEXPR_CHECK(prepend(1, make('2', 3.3)) == make(1, '2', 3.3)); BOOST_HANA_CONSTEXPR_CHECK( prepend(1, prepend('2', prepend(3.3, make()))) == make(1, '2', 3.3) ); //! [prepend] }{ //! [append] BOOST_HANA_CONSTEXPR_CHECK(append(make(), 1) == make(1)); BOOST_HANA_CONSTEXPR_CHECK(append(make(1, '2'), 3.3) == make(1, '2', 3.3)); BOOST_HANA_CONSTEXPR_CHECK( append(append(append(make(), 1), '2'), 3.3) == make(1, '2', 3.3) ); //! [append] }{ //! [filter] static_assert(filter(make(1, 2.0, 3, 4.0), trait) == make(1, 3), ""); static_assert(filter(just(3), trait) == just(3), ""); BOOST_HANA_CONSTANT_CHECK(filter(just(3.0), trait) == nothing); //! [filter] }{ //! [cycle] static_assert(cycle(size_t<2>, make('x', 'y')) == make('x', 'y', 'x', 'y'), ""); //! [cycle] }{ //! [remove_if] static_assert(remove_if(make(1, 2.0, 3, 4.0), trait) == make(2.0, 4.0), ""); static_assert(remove_if(just(3.0), trait) == just(3.0), ""); BOOST_HANA_CONSTANT_CHECK(remove_if(just(3), trait) == nothing); //! [remove_if] }{ using boost::hana::remove; // Make sure we don't clash with ::remove from //! [remove] BOOST_HANA_CONSTANT_CHECK(remove(tuple_t, type) == tuple_t); BOOST_HANA_CONSTANT_CHECK(remove(just(type), type) == just(type)); BOOST_HANA_CONSTANT_CHECK(remove(just(type), type) == nothing); //! [remove] }{ //! [repeat] BOOST_HANA_CONSTEXPR_CHECK(repeat(size_t<2>, 'x') == make('x', 'x')); // Of course, there can't be more than one element in a Maybe. static_assert(repeat(size_t<2>, 'x') == just('x'), ""); //! [repeat] }{ //! [prefix] using namespace std::literals; BOOST_HANA_RUNTIME_CHECK( prefix("my"s, make("dog"s, "car"s, "house"s)) == make("my", "dog", "my", "car", "my", "house") ); //! [prefix] }{ //! [suffix] BOOST_HANA_CONSTEXPR_CHECK( suffix(0, make(1, 2, 3, 4)) == make(1, 0, 2, 0, 3, 0, 4, 0) ); //! [suffix] } }