// Copyright Louis Dionne 2013-2017 // 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 #include #include #include #include #include #include #include namespace hana = boost::hana; namespace mpl = boost::mpl; namespace with_mpl { //! [mpl] using types = mpl::vector; using number_of_floats = mpl::fold< types, mpl::int_<0>, mpl::if_, mpl::next, mpl::_1 > >::type; static_assert(number_of_floats::value == 3, ""); //! [mpl] } namespace with_hana { //! [hana] constexpr auto types = hana::tuple_t; BOOST_HANA_CONSTEXPR_LAMBDA auto number_of_floats = hana::fold_left( types, hana::int_c<0>, [](auto count, auto t) { return hana::if_(hana::trait(t), count + hana::int_c<1>, count ); } ); BOOST_HANA_CONSTANT_CHECK(number_of_floats == hana::int_c<3>); //! [hana] } int main() { }