/* @copyright Louis Dionne 2014 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 using namespace boost::hana; int main() { { //! [tuple_c] BOOST_HANA_CONSTANT_CHECK( to(tuple_c) == tuple(int_<0>, int_<1>, int_<2>) ); BOOST_HANA_CONSTANT_CHECK(head(tuple_c) == int_<0>); //! [tuple_c] }{ //! [Foldable] using namespace literals; constexpr auto numbers = tuple_c; constexpr auto negatives = tuple_c; BOOST_HANA_CONSTEXPR_LAMBDA auto keep_negatives = [](auto n, auto acc) { return if_(n < 0_c, prepend(n, acc), acc); }; BOOST_HANA_CONSTANT_CHECK(foldr(numbers, tuple_c, keep_negatives) == negatives); //! [Foldable] }{ //! [Tuple_interop] BOOST_HANA_CONSTEXPR_CHECK( to(std::make_tuple(1, '2', 3.3)) == tuple(1, '2', 3.3) ); BOOST_HANA_CONSTANT_CHECK( to(range(int_<1>, int_<4>)) == tuple(int_<1>, int_<2>, int_<3>) ); BOOST_HANA_CONSTEXPR_CHECK( to(std::array{{1, 2, 3}}) == tuple(1, 2, 3) ); //! [Tuple_interop] } }