]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/example/type/typeid.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / type / typeid.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/remove_if.hpp>
8#include <boost/hana/tuple.hpp>
9#include <boost/hana/type.hpp>
10
11#include <string>
12namespace hana = boost::hana;
13
14
15struct Cat { std::string name; };
16struct Dog { std::string name; };
17struct Fish { std::string name; };
18
19bool operator==(Cat const& a, Cat const& b) { return a.name == b.name; }
20bool operator!=(Cat const& a, Cat const& b) { return a.name != b.name; }
21bool operator==(Dog const& a, Dog const& b) { return a.name == b.name; }
22bool operator!=(Dog const& a, Dog const& b) { return a.name != b.name; }
23bool operator==(Fish const& a, Fish const& b) { return a.name == b.name; }
24bool operator!=(Fish const& a, Fish const& b) { return a.name != b.name; }
25
26int main() {
27 hana::tuple<Cat, Fish, Dog, Fish> animals{
28 Cat{"Garfield"}, Fish{"Jaws"}, Dog{"Beethoven"}, Fish{"Nemo"}
29 };
30
31 auto mammals = hana::remove_if(animals, [](auto const& a) {
32 return hana::typeid_(a) == hana::type<Fish>{};
33 });
34
35 BOOST_HANA_RUNTIME_CHECK(mammals == hana::make_tuple(Cat{"Garfield"}, Dog{"Beethoven"}));
36}