]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fusion/test/algorithm/segmented_find.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / fusion / test / algorithm / segmented_find.cpp
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 <boost/detail/lightweight_test.hpp>
9 #include <boost/fusion/container/vector/vector.hpp>
10 #include <boost/fusion/algorithm/query/find.hpp>
11 #include <boost/fusion/container/generation/make_vector.hpp>
12 #include "../sequence/tree.hpp"
13
14 struct not_there {};
15
16 template<typename Tree>
17 void
18 process_tree(Tree const &tree)
19 {
20 using namespace boost;
21
22 typedef typename boost::fusion::result_of::find<Tree const, short>::type short_iter;
23 typedef typename boost::fusion::result_of::find<Tree const, float>::type float_iter;
24 typedef typename boost::fusion::result_of::find<Tree const, not_there>::type not_there_iter;
25
26 // find_if_s of a segmented data structure returns generic
27 // segmented iterators
28 short_iter si = fusion::find<short>(tree);
29 float_iter fi = fusion::find<float>(tree);
30
31 // they behave like ordinary Fusion iterators ...
32 BOOST_TEST((*si == short('d')));
33 BOOST_TEST((*fi == float(1)));
34
35 // Searching for something that's not there should return the end iterator.
36 not_there_iter nti = fusion::find<not_there>(tree);
37 BOOST_TEST((nti == fusion::end(tree)));
38 }
39
40 int
41 main()
42 {
43 using namespace boost::fusion;
44 process_tree(
45 make_tree(
46 make_vector(double(0),'B')
47 , make_tree(
48 make_vector(1,2,long(3))
49 , make_tree(make_vector('a','b','c'))
50 , make_tree(make_vector(short('d'),'e','f'))
51 )
52 , make_tree(
53 make_vector(4,5,6)
54 , make_tree(make_vector(float(1),'h','i'))
55 , make_tree(make_vector('j','k','l'))
56 )
57 )
58 );
59
60 return boost::report_errors();
61 }
62