Imported Upstream version 1.64.0
[platform/upstream/boost.git] / libs / hana / example / any_of.cpp
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)
4
5 #include <boost/hana/any_of.hpp>
6 #include <boost/hana/assert.hpp>
7 #include <boost/hana/config.hpp>
8 #include <boost/hana/ext/std/integral_constant.hpp>
9 #include <boost/hana/integral_constant.hpp>
10 #include <boost/hana/mod.hpp>
11 #include <boost/hana/not.hpp>
12 #include <boost/hana/not_equal.hpp>
13 #include <boost/hana/traits.hpp>
14 #include <boost/hana/tuple.hpp>
15 #include <boost/hana/type.hpp>
16
17 #include <type_traits>
18 namespace hana = boost::hana;
19 using namespace hana::literals;
20
21
22 BOOST_HANA_CONSTEXPR_LAMBDA auto is_odd = [](auto x) {
23     return x % 2_c != 0_c;
24 };
25
26 int main() {
27     BOOST_HANA_CONSTEXPR_CHECK(hana::any_of(hana::make_tuple(1, 2), is_odd));
28     BOOST_HANA_CONSTANT_CHECK(!hana::any_of(hana::make_tuple(2_c, 4_c), is_odd));
29
30     BOOST_HANA_CONSTANT_CHECK(
31       hana::any_of(hana::make_tuple(hana::type<void>{}, hana::type<char&>{}),
32                    hana::traits::is_void)
33     );
34
35     BOOST_HANA_CONSTANT_CHECK(
36       !hana::any_of(hana::make_tuple(hana::type<void>{}, hana::type<char&>{}),
37                     hana::traits::is_integral)
38     );
39 }