]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/hana/example/tap.cpp
165f878a1c7f0ed0b2ce32fdf85c208b774b8287
1 // Copyright Louis Dionne 2013-2016
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)
5 #include <boost/hana/assert.hpp>
6 #include <boost/hana/chain.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/tap.hpp>
9 #include <boost/hana/tuple.hpp>
12 namespace hana
= boost::hana
;
16 // We use a sorted container because the order in which the functions
17 // are called is unspecified.
18 std::set
<int> before
, after
;
20 auto xs
= hana::make_tuple(1, 2, 3)
21 | hana::tap
<hana::tuple_tag
>([&](int x
) { before
.insert(x
); })
22 | [](auto x
) { return hana::make_tuple(x
, -x
); }
23 | hana::tap
<hana::tuple_tag
>([&](int x
) { after
.insert(x
); });
25 BOOST_HANA_RUNTIME_CHECK(before
== std::set
<int>{1, 2, 3});
26 BOOST_HANA_RUNTIME_CHECK(after
== std::set
<int>{1, -1, 2, -2, 3, -3});
27 BOOST_HANA_RUNTIME_CHECK(xs
== hana::make_tuple(1, -1, 2, -2, 3, -3));