]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fusion/test/algorithm/find.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
7 #include <boost/detail/lightweight_test.hpp>
8 #include <boost/fusion/container/vector/vector.hpp>
9 #include <boost/fusion/adapted/mpl.hpp>
10 #include <boost/fusion/container/set/set.hpp>
11 #include <boost/fusion/container/map/map.hpp>
12 #include <boost/fusion/algorithm/query/find.hpp>
13 #include <boost/fusion/iterator/deref.hpp>
14 #include <boost/mpl/vector.hpp>
27 using namespace boost::fusion
;
28 using boost::mpl::identity
;
31 typedef vector
<int, char, int, double> seq_type
;
32 seq_type
seq(12345, 'x', 678910, 3.36);
34 std::cout
<< *boost::fusion::find
<char>(seq
) << std::endl
;
35 BOOST_TEST(*boost::fusion::find
<char>(seq
) == 'x');
37 std::cout
<< *boost::fusion::find
<int>(seq
) << std::endl
;
38 BOOST_TEST(*boost::fusion::find
<int>(seq
) == 12345);
40 std::cout
<< *boost::fusion::find
<double>(seq
) << std::endl
;
41 BOOST_TEST(*boost::fusion::find
<double>(seq
) == 3.36);
43 BOOST_TEST(boost::fusion::find
<bool>(seq
) == boost::fusion::end(seq
));
47 typedef set
<int, char, double> seq_type
;
48 seq_type
seq(12345, 'x', 3.36);
49 std::cout
<< *boost::fusion::find
<char>(seq
) << std::endl
;
50 BOOST_TEST(*boost::fusion::find
<char>(seq
) == 'x');
51 BOOST_TEST(boost::fusion::find
<bool>(seq
) == boost::fusion::end(seq
));
57 , pair
<double, std::string
> >
62 , make_pair
<double>("Men"));
64 std::cout
<< *boost::fusion::find
<int>(seq
) << std::endl
;
65 std::cout
<< *boost::fusion::find
<double>(seq
) << std::endl
;
66 BOOST_TEST((*boost::fusion::find
<int>(seq
)).second
== 'X');
67 BOOST_TEST((*boost::fusion::find
<double>(seq
)).second
== "Men");
68 BOOST_TEST(boost::fusion::find
<bool>(seq
) == boost::fusion::end(seq
));
72 typedef boost::mpl::vector
<int, char, X
, double> mpl_vec
;
73 BOOST_TEST((*boost::fusion::find
<X
>(mpl_vec()) == 12345));
74 BOOST_TEST(boost::fusion::find
<bool>(mpl_vec()) == boost::fusion::end(mpl_vec()));
77 return boost::report_errors();