1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2007 Dan Marsden
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/adapted/mpl.hpp>
11 #include <boost/fusion/algorithm/query/all.hpp>
12 #include <boost/lambda/lambda.hpp>
13 #include <boost/mpl/vector_c.hpp>
14
15 namespace
16 {
17 struct search_for
18 {
search_for__anonbb3223480111::search_for19 explicit search_for(int in_search)
20 : search(in_search)
21 {}
22
23 template<typename T>
operator ()__anonbb3223480111::search_for24 bool operator()(T const& v) const
25 {
26 return v == search;
27 }
28
29 int search;
30 };
31 }
32
33 int
main()34 main()
35 {
36 {
37 boost::fusion::vector<> t;
38 BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 < 4)));
39 BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 > 0)));
40 }
41
42 {
43 boost::fusion::vector<int, short, double> t(1, 2, 3.3);
44 BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 < 4)));
45 BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 > 0)));
46 }
47
48 {
49 boost::fusion::vector<int, short, double, long> t(1, 2, 3.3, 2);
50 BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 < 4)));
51 BOOST_TEST((boost::fusion::all(t, boost::lambda::_1 > 0)));
52 }
53
54 {
55 boost::fusion::vector<int, short, double> t(1, 2, 3.3);
56 BOOST_TEST((!boost::fusion::all(t, boost::lambda::_1 == 1)));
57 BOOST_TEST((!boost::fusion::all(t, boost::lambda::_1 < 3)));
58 }
59
60 {
61 typedef boost::mpl::vector_c<int, 1> mpl_vec;
62 // We cannot use lambda here as mpl vec iterators return
63 // rvalues, and lambda needs lvalues.
64 BOOST_TEST(boost::fusion::all(mpl_vec(), search_for(1)));
65 BOOST_TEST(!boost::fusion::all(mpl_vec(), search_for(2)));
66 }
67
68 return boost::report_errors();
69 }
70
71