]>
Commit | Line | Data |
---|---|---|
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> | |
12 | namespace hana = boost::hana; | |
13 | ||
14 | ||
15 | struct Cat { std::string name; }; | |
16 | struct Dog { std::string name; }; | |
17 | struct Fish { std::string name; }; | |
18 | ||
19 | bool operator==(Cat const& a, Cat const& b) { return a.name == b.name; } | |
20 | bool operator!=(Cat const& a, Cat const& b) { return a.name != b.name; } | |
21 | bool operator==(Dog const& a, Dog const& b) { return a.name == b.name; } | |
22 | bool operator!=(Dog const& a, Dog const& b) { return a.name != b.name; } | |
23 | bool operator==(Fish const& a, Fish const& b) { return a.name == b.name; } | |
24 | bool operator!=(Fish const& a, Fish const& b) { return a.name != b.name; } | |
25 | ||
26 | int 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 | } |