• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*=============================================================================
2     Copyright (c) 2001-2011 Joel de Guzman
3     Copyright (c) 2005 Eric Niebler
4     Copyright (c) Dan Marsden
5 
6     Distributed under the Boost Software License, Version 1.0. (See accompanying
7     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
8 ==============================================================================*/
9 #include <boost/detail/lightweight_test.hpp>
10 #include <boost/fusion/container/vector/vector.hpp>
11 #include <boost/fusion/adapted/mpl.hpp>
12 #include <boost/fusion/algorithm/query/any.hpp>
13 #include <boost/lambda/lambda.hpp>
14 #include <boost/mpl/vector_c.hpp>
15 
16 namespace
17 {
18     struct search_for
19     {
search_for__anonc0c7b3170111::search_for20         explicit search_for(int in_search)
21             : search(in_search)
22         {}
23 
24         template<typename T>
operator ()__anonc0c7b3170111::search_for25         bool operator()(T const& v) const
26         {
27             return v == search;
28         }
29 
30         int search;
31     };
32 }
33 
34 int
main()35 main()
36 {
37     {
38         boost::fusion::vector<int, short, double> t(1, 2, 3.3);
39         BOOST_TEST(boost::fusion::any(t, boost::lambda::_1 == 2));
40     }
41 
42     {
43         boost::fusion::vector<int, short, double> t(1, 2, 3.3);
44         BOOST_TEST(!boost::fusion::any(t, boost::lambda::_1 == 3));
45     }
46 
47     {
48         typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
49         // We cannot use lambda here as mpl vec iterators return
50         // rvalues, and lambda needs lvalues.
51         BOOST_TEST(boost::fusion::any(mpl_vec(), search_for(2)));
52         BOOST_TEST(!boost::fusion::any(mpl_vec(), search_for(4)));
53     }
54 
55     return boost::report_errors();
56 }
57 
58