]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/fusion/test/algorithm/count_if.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / fusion / test / algorithm / count_if.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2011 Joel de Guzman
3 Copyright (c) 2005 Eric Niebler
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/count_if.hpp>
12 #include <boost/lambda/lambda.hpp>
13 #include <boost/mpl/vector_c.hpp>
14 #include <functional>
15
16 int
17 main()
18 {
19 {
20 boost::fusion::vector<int, short, double> t(1, 2, 3.3);
21 BOOST_TEST(boost::fusion::count_if(t, boost::lambda::_1 == 2) == 1);
22 }
23
24 {
25 boost::fusion::vector<int, short, double> t(1, 2, 3.3);
26 BOOST_TEST(boost::fusion::count_if(t, boost::lambda::_1 == 3) == 0);
27 }
28
29 {
30 typedef boost::mpl::vector_c<int, 1, 2, 3> mpl_vec;
31 // Cannot use lambda here as mpl iterators return rvalues and lambda needs lvalues
32 BOOST_TEST(boost::fusion::count_if(mpl_vec(), std::bind2nd(std::less_equal<int>(), 2)) == 2);
33 BOOST_TEST(boost::fusion::count_if(mpl_vec(), std::bind2nd(std::greater<int>(), 2)) == 1);
34 }
35
36 return boost::report_errors();
37 }
38