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/none.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__anon1f23314d0111::search_for19         explicit search_for(int in_search)
20             : search(in_search)
21         {}
22 
23         template<typename T>
operator ()__anon1f23314d0111::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<int, short, double> t(1, 2, 3.3);
38         BOOST_TEST((boost::fusion::none(t, boost::lambda::_1 > 4)));
39         BOOST_TEST((boost::fusion::none(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::none(t, boost::lambda::_1 == 1)));
45         BOOST_TEST((!boost::fusion::none(t, boost::lambda::_1 < 3)));
46     }
47 
48     {
49         typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
50         // We cannot use lambda here as mpl vec iterators return
51         // rvalues, and lambda needs lvalues.
52         BOOST_TEST(boost::fusion::none(mpl_vec(), search_for(4)));
53         BOOST_TEST(!boost::fusion::none(mpl_vec(), search_for(3)));
54     }
55 
56     return boost::report_errors();
57 }
58 
59