]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/example/find_if.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / find_if.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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/assert.hpp>
6#include <boost/hana/equal.hpp>
7#include <boost/hana/equal.hpp>
8#include <boost/hana/ext/std/integral_constant.hpp>
9#include <boost/hana/find_if.hpp>
10#include <boost/hana/functional/compose.hpp>
11#include <boost/hana/optional.hpp>
12#include <boost/hana/tuple.hpp>
13#include <boost/hana/type.hpp>
14
15#include <type_traits>
16namespace hana = boost::hana;
17
18
19// First get the type of the object, and then call the trait on it.
20constexpr auto is_integral = hana::compose(hana::trait<std::is_integral>, hana::typeid_);
21constexpr auto is_class = hana::compose(hana::trait<std::is_class>, hana::typeid_);
22
23static_assert(
24 hana::find_if(hana::make_tuple(1.0, 2, '3'), is_integral) == hana::just(2)
25, "");
26
27BOOST_HANA_CONSTANT_CHECK(
28 hana::find_if(hana::make_tuple(1.0, 2, '3'), is_class) == hana::nothing
29);
30
31constexpr auto types = hana::tuple_t<char, int, unsigned, long, unsigned long>;
32BOOST_HANA_CONSTANT_CHECK(
33 hana::find_if(types, hana::equal.to(hana::type_c<unsigned>)) == hana::just(hana::type_c<unsigned>)
34);
35BOOST_HANA_CONSTANT_CHECK(
36 hana::find_if(types, hana::equal.to(hana::type_c<void>)) == hana::nothing
37);
38
39int main() { }