1 // Copyright Louis Dionne 2013-2017
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/chain.hpp>
7 #include <boost/hana/equal.hpp>
8 #include <boost/hana/tap.hpp>
9 #include <boost/hana/tuple.hpp>
10 
11 #include <set>
12 namespace hana = boost::hana;
13 
14 
main()15 int main() {
16     // We use a sorted container because the order in which the functions
17     // are called is unspecified.
18     std::set<int> before, after;
19 
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); });
24 
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));
28 }
29