1// Copyright Louis Dionne 2013-2022
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{.name: "Garfield"}, Fish{.name: "Jaws"}, Dog{.name: "Beethoven"}, Fish{.name: "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}
37

source code of boost/libs/hana/example/type/typeid.cpp