]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/example/transform.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / hana / example / transform.cpp
CommitLineData
b32b8144 1// Copyright Louis Dionne 2013-2017
7c673cae
FG
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>
15namespace hana = boost::hana;
16using namespace std::literals;
17
18
19auto to_string = [](auto x) {
20 std::ostringstream ss;
21 ss << x;
22 return ss.str();
23};
24
25int 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(
92f5a8d4 36 hana::transform(hana::tuple_t<void, int(), char[10]>, hana::metafunction<std::add_pointer>)
7c673cae
FG
37 ==
38 hana::tuple_t<void*, int(*)(), char(*)[10]>
39 );
40}