2
0
mirror of https://github.com/boostorg/hana.git synced 2026-02-01 20:42:13 +00:00
Files
hana/example/tutorial/rationale.container.cpp
Louis Dionne cf063a4fe3 Return hana::integral_constants from type_traits adapters
Also, remove the ext/std/{type_traits,utility} headers in favour of the
<boost/hana/traits.hpp> header.
2015-09-21 07:45:04 -07:00

55 lines
1.1 KiB
C++

/*
@copyright Louis Dionne 2015
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
*/
#include <boost/hana.hpp>
#include <boost/fusion/include/find_if.hpp>
#include <boost/fusion/include/make_vector.hpp>
#include <boost/mpl/quote.hpp>
#include <type_traits>
namespace fusion = boost::fusion;
namespace mpl = boost::mpl;
namespace hana = boost::hana;
int main() {
{
//! [hana]
auto tuple = hana::make_tuple(1, 'x', 3.4f);
auto result = hana::find_if(tuple, [](auto const& x) {
return hana::traits::is_integral(x);
});
//! [hana]
(void)result;
#if 0
//! [hana-explicit]
some_type result = hana::find_if(tuple, [](auto const& x) {
return hana::traits::is_integral(x);
});
//! [hana-explicit]
#endif
}{
//! [fusion]
using Container = fusion::result_of::make_vector<int, char, float>::type;
Container tuple = fusion::make_vector(1, 'x', 3.4f);
using Predicate = mpl::quote1<std::is_integral>;
using Result = fusion::result_of::find_if<Container, Predicate>::type;
Result result = fusion::find_if<Predicate>(tuple);
//! [fusion]
(void)result;
}
}