]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/algorithm/querying_find.cpp
1 /*=============================================================================
2 Copyright (c) 2005 Dan Marsden
3 Copyright (c) 2005-2007 Joel de Guzman
4 Copyright (c) 2007 Hartmut Kaiser
5 Copyright (c) 2015 John Fletcher
7 Distributed under the Boost Software License, Version 1.0. (See accompanying
8 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 ==============================================================================*/
11 #include <boost/phoenix/core.hpp>
12 #include <boost/phoenix/stl/algorithm/querying.hpp>
13 #include <boost/detail/lightweight_test.hpp>
14 #include <boost/assign/list_of.hpp>
16 #include <boost/config.hpp>
18 #ifdef BOOST_PHOENIX_HAS_HASH
19 #include BOOST_PHOENIX_HASH_SET_HEADER
20 #include BOOST_PHOENIX_HASH_MAP_HEADER
22 #ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP
23 #include BOOST_PHOENIX_UNORDERED_SET_HEADER
24 #include BOOST_PHOENIX_UNORDERED_MAP_HEADER
35 bool operator()(const int i
) const
41 struct mod_2_comparison
47 return lhs
% 2 == rhs
% 2;
53 using boost::phoenix::arg_names::arg1
;
54 int array
[] = {1,2,3};
55 BOOST_TEST(boost::phoenix::find(arg1
,2)(array
) == array
+ 1);
57 std::set
<int> s(array
, array
+ 3);
58 BOOST_TEST(boost::phoenix::find(arg1
, 2)(s
) == s
.find(2));
60 //#if !(defined(BOOST_MSVC) && (BOOST_MSVC >= 1900))
61 //std::map<int, int> m = boost::assign::map_list_of(0, 1)(2, 3)(4, 5).to_container(m);
62 std::map
<int, int> m
= boost::assign::map_list_of(0, 1)(2, 3)(4, 5).
63 convert_to_container
<std::map
<int, int> >();
64 BOOST_TEST(boost::phoenix::find(arg1
, 2)(m
) == m
.find(2));
67 #ifdef BOOST_PHOENIX_HAS_HASH
69 BOOST_PHOENIX_HASH_NAMESPACE::hash_set
<int> hs(array
, array
+ 3);
70 BOOST_TEST(boost::phoenix::find(arg1
, 2)(hs
) == hs
.find(2));
72 BOOST_PHOENIX_HASH_NAMESPACE::hash_map
<int, int> hm
= boost::assign::map_list_of(0, 1)(2, 3)(4, 5).
73 convert_to_container
<BOOST_PHOENIX_HASH_NAMESPACE::hash_map
<int, int> >();
74 BOOST_TEST(boost::phoenix::find(arg1
, 2)(hm
) == hm
.find(2));
77 #ifdef BOOST_PHOENIX_HAS_UNORDERED_SET_AND_MAP
79 std::unordered_set
<int> us(array
, array
+ 3);
80 BOOST_TEST(boost::phoenix::find(arg1
, 2)(us
) == us
.find(2));
82 std::unordered_map
<int, int> um
= boost::assign::map_list_of(0, 1)(2, 3)(4, 5).
83 convert_to_container
<std::unordered_map
<int, int> >();
84 BOOST_TEST(boost::phoenix::find(arg1
, 2)(um
) == um
.find(2));
94 return boost::report_errors();