]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/example/reverse_fold.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / hana / example / reverse_fold.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/reverse_fold.hpp>
7#include <boost/hana/tuple.hpp>
8
9#include <sstream>
10#include <string>
11namespace hana = boost::hana;
12
13
14auto to_string = [](auto x) {
15 std::ostringstream ss;
16 ss << x;
17 return ss.str();
18};
19
20int main() {
21 auto f = [=](std::string s, auto element) {
22 return "f(" + s + ", " + to_string(element) + ")";
23 };
24
25 // With an initial state
26 BOOST_HANA_RUNTIME_CHECK(
27 hana::reverse_fold(hana::make_tuple(1, '2', 3.0, 4), "5", f)
28 ==
29 "f(f(f(f(5, 4), 3), 2), 1)"
30 );
31
32 // Without an initial state
33 BOOST_HANA_RUNTIME_CHECK(
34 hana::reverse_fold(hana::make_tuple(1, '2', 3.0, 4, "5"), f)
35 ==
36 "f(f(f(f(5, 4), 3), 2), 1)"
37 );
38}