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.hpp>
6
7#include <boost/fusion/include/find_if.hpp>
8#include <boost/fusion/include/make_vector.hpp>
9#include <boost/mpl/quote.hpp>
10
11#include <type_traits>
12namespace fusion = boost::fusion;
13namespace mpl = boost::mpl;
14namespace hana = boost::hana;
15
16
17int main() {
18
19{
20
21//! [hana]
22auto tuple = hana::make_tuple(1, 'x', 3.4f);
23
24auto result = hana::find_if(tuple, [](auto const& x) {
25 return hana::traits::is_integral(hana::typeid_(x));
26});
27//! [hana]
28(void)result;
29
30#if 0
31//! [hana-explicit]
32some_type result = hana::find_if(tuple, [](auto const& x) {
33 return hana::traits::is_integral(hana::typeid_(x));
34});
35//! [hana-explicit]
36#endif
37
38}{
39
40//! [fusion]
41using Container = fusion::result_of::make_vector<int, char, float>::type;
42Container tuple = fusion::make_vector(arg: 1, arg: 'x', arg: 3.4f);
43
44using Predicate = mpl::quote1<std::is_integral>;
45using Result = fusion::result_of::find_if<Container, Predicate>::type;
46Result result = fusion::find_if<Predicate>(seq&: tuple);
47//! [fusion]
48(void)result;
49
50}
51
52}
53

source code of boost/libs/hana/example/tutorial/rationale.container.cpp