]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/fusion/test/algorithm/segmented_fold.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / fusion / test / algorithm / segmented_fold.cpp
CommitLineData
7c673cae
FG
1/*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2011 Eric Niebler
4
5 Distributed under the Boost Software License, Version 1.0. (See accompanying
6 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7==============================================================================*/
8#include <string>
9#include <sstream>
10#include <iostream>
11#include <boost/detail/lightweight_test.hpp>
12#include <boost/fusion/container/vector/vector.hpp>
13#include <boost/fusion/algorithm/iteration/fold.hpp>
14#include <boost/fusion/container/generation/make_vector.hpp>
15#include "../sequence/tree.hpp"
16
17struct write_string
18{
19 typedef std::ostream* result_type;
20
21 template<typename T>
22 std::ostream* operator()(std::ostream* sout, T const& t) const
23 {
24 return &(*sout << t << " ");
25 }
26};
27
28template<typename Tree>
29void
30process_tree(Tree const &tree)
31{
32 using namespace boost;
33
34 std::stringstream str;
35 fusion::fold(tree, &str, write_string());
36 std::string res = str.str();
37
38 BOOST_TEST_EQ(res, "a b c 1 2 3 100 e f 0 B 1 h i 4 5 6 j k l ");
39}
40
41int
42main()
43{
44 using namespace boost::fusion;
45 process_tree(
46 make_tree(
47 make_vector(double(0),'B')
48 , make_tree(
49 make_vector(1,2,long(3))
50 , make_tree(make_vector('a','b','c'))
51 , make_tree(make_vector(short('d'),'e','f'))
52 )
53 , make_tree(
54 make_vector(4,5,6)
55 , make_tree(make_vector(float(1),'h','i'))
56 , make_tree(make_vector('j','k','l'))
57 )
58 )
59 );
60
61 return boost::report_errors();
62}
63