| 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/ext/boost/tuple.hpp> |
| 8 | #include <boost/hana/integral_constant.hpp> |
| 9 | #include <boost/hana/transform.hpp> |
| 10 | |
| 11 | #include <boost/tuple/tuple.hpp> |
| 12 | |
| 13 | #include <string> |
| 14 | namespace hana = boost::hana; |
| 15 | |
| 16 | |
| 17 | struct Fish { std::string name; }; |
| 18 | struct Cat { std::string name; }; |
| 19 | struct Dog { std::string name; }; |
| 20 | |
| 21 | int main() { |
| 22 | boost::tuple<Fish, Cat, Dog> animals{{.name: "Nemo"}, {.name: "Garfield"}, {.name: "Snoopy"}}; |
| 23 | hana::front(animals).name = "Moby Dick"; |
| 24 | |
| 25 | auto names = hana::transform(animals, [](auto a) { |
| 26 | return a.name; |
| 27 | }); |
| 28 | |
| 29 | BOOST_HANA_RUNTIME_CHECK(hana::equal( |
| 30 | names, |
| 31 | boost::make_tuple("Moby Dick", "Garfield", "Snoopy") |
| 32 | )); |
| 33 | } |
| 34 |
