]>
Commit | Line | Data |
---|---|---|
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/equal.hpp> | |
7 | #include <boost/hana/optional.hpp> | |
8 | #include <boost/hana/transform.hpp> | |
9 | #include <boost/hana/tuple.hpp> | |
10 | #include <boost/hana/type.hpp> | |
11 | ||
12 | #include <sstream> | |
13 | #include <string> | |
14 | #include <type_traits> | |
15 | namespace hana = boost::hana; | |
16 | using namespace std::literals; | |
17 | ||
18 | ||
19 | auto to_string = [](auto x) { | |
20 | std::ostringstream ss; | |
21 | ss << x; | |
22 | return ss.str(); | |
23 | }; | |
24 | ||
25 | int main() { | |
26 | BOOST_HANA_RUNTIME_CHECK( | |
27 | hana::transform(hana::make_tuple(1, '2', "345", std::string{"67"}), to_string) | |
28 | == | |
29 | hana::make_tuple("1", "2", "345", "67") | |
30 | ); | |
31 | ||
32 | BOOST_HANA_CONSTANT_CHECK(hana::transform(hana::nothing, to_string) == hana::nothing); | |
33 | BOOST_HANA_RUNTIME_CHECK(hana::transform(hana::just(123), to_string) == hana::just("123"s)); | |
34 | ||
35 | BOOST_HANA_CONSTANT_CHECK( | |
36 | hana::transform(hana::tuple_t<void, int(), char[10]>, hana::template_<std::add_pointer_t>) | |
37 | == | |
38 | hana::tuple_t<void*, int(*)(), char(*)[10]> | |
39 | ); | |
40 | } |