]>
git.proxmox.com Git - ceph.git/blob - 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
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"
16 template<typename Tree
>
18 process_tree(Tree
const &tree
)
20 using namespace boost
;
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
;
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
);
31 // they behave like ordinary Fusion iterators ...
32 BOOST_TEST((*si
== short('d')));
33 BOOST_TEST((*fi
== float(1)));
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
)));
43 using namespace boost::fusion
;
46 make_vector(double(0),'B')
48 make_vector(1,2,long(3))
49 , make_tree(make_vector('a','b','c'))
50 , make_tree(make_vector(short('d'),'e','f'))
54 , make_tree(make_vector(float(1),'h','i'))
55 , make_tree(make_vector('j','k','l'))
60 return boost::report_errors();