1 // Copyright Louis Dionne 2013-2017
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)
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/config.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/ext/boost/mpl/vector.hpp>
9 #include <boost/hana/ext/std/integral_constant.hpp>
10 #include <boost/hana/integral_constant.hpp>
11 #include <boost/hana/plus.hpp>
12 #include <boost/hana/tuple.hpp>
14 #include <boost/mpl/fold.hpp>
15 #include <boost/mpl/if.hpp>
16 #include <boost/mpl/int.hpp>
17 #include <boost/mpl/next.hpp>
18 #include <boost/mpl/placeholders.hpp>
19 #include <boost/mpl/vector.hpp>
21 #include <type_traits>
22 namespace hana
= boost::hana
;
23 namespace mpl
= boost::mpl
;
28 using types
= mpl::vector
<long, float, short, float, long, long double>;
29 using number_of_floats
= mpl::fold
<
32 mpl::if_
<std::is_floating_point
<mpl::_2
>,
37 static_assert(number_of_floats::value
== 3, "");
43 constexpr auto types
= hana::tuple_t
<long, float, short, float, long, long double>;
44 BOOST_HANA_CONSTEXPR_LAMBDA
auto number_of_floats
= hana::fold_left(
47 [](auto count
, auto t
) {
48 return hana::if_(hana::trait
<std::is_floating_point
>(t
),
49 count
+ hana::int_c
<1>,
54 BOOST_HANA_CONSTANT_CHECK(number_of_floats
== hana::int_c
<3>);