]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/container/test/flat_map_adaptor_test.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / container / test / flat_map_adaptor_test.cpp
CommitLineData
92f5a8d4
TL
1//////////////////////////////////////////////////////////////////////////////
2//
3// (C) Copyright Ion Gaztanaga 2004-2019. Distributed under the Boost
4// Software License, Version 1.0. (See accompanying file
5// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6//
7// See http://www.boost.org/libs/container for documentation.
8//
9//////////////////////////////////////////////////////////////////////////////
10#include <boost/container/flat_map.hpp>
11#include <boost/container/small_vector.hpp>
12#include <boost/container/static_vector.hpp>
13#include <boost/container/stable_vector.hpp>
14#include <boost/container/vector.hpp>
20effc67 15#include <boost/container/devector.hpp>
92f5a8d4 16#include <boost/container/deque.hpp>
20effc67 17#include <boost/static_assert.hpp>
92f5a8d4
TL
18
19#include <boost/container/detail/container_or_allocator_rebind.hpp>
20
21#include "map_test.hpp"
22#include <map>
23
24using namespace boost::container;
25
26template<class VoidAllocatorOrContainer>
27struct GetMapContainer
28{
29 template<class ValueType>
30 struct apply
31 {
32 typedef std::pair<ValueType, ValueType> type_t;
33 typedef flat_map< ValueType
34 , ValueType
35 , std::less<ValueType>
36 , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, type_t>::type
37 > map_type;
38
39 typedef flat_multimap< ValueType
40 , ValueType
41 , std::less<ValueType>
42 , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, type_t>::type
43 > multimap_type;
44 };
45};
46
47int main()
48{
49 using namespace boost::container::test;
50
51 ////////////////////////////////////
52 // Testing sequence container implementations
53 ////////////////////////////////////
54 {
55 typedef std::map<int, int> MyStdMap;
56 typedef std::multimap<int, int> MyStdMultiMap;
57
58 if (0 != test::map_test
59 < GetMapContainer<vector<std::pair<int, int> > >::apply<int>::map_type
60 , MyStdMap
61 , GetMapContainer<vector<std::pair<int, int> > >::apply<int>::multimap_type
62 , MyStdMultiMap>()) {
63 std::cout << "Error in map_test<vector<std::pair<int, int> > >" << std::endl;
64 return 1;
65 }
66
67 if (0 != test::map_test
68 < GetMapContainer<small_vector<std::pair<int, int>, 7> >::apply<int>::map_type
69 , MyStdMap
70 , GetMapContainer<small_vector<std::pair<int, int>, 7> >::apply<int>::multimap_type
71 , MyStdMultiMap>()) {
72 std::cout << "Error in map_test<small_vector<std::pair<int, int>, 7> >" << std::endl;
73 return 1;
74 }
75
76 if (0 != test::map_test
77 < GetMapContainer<static_vector<std::pair<int, int>, MaxElem * 10> >::apply<int>::map_type
78 , MyStdMap
79 , GetMapContainer<static_vector<std::pair<int, int>, MaxElem * 10> >::apply<int>::multimap_type
80 , MyStdMultiMap>()) {
81 std::cout << "Error in map_test<static_vector<std::pair<int, int>, MaxElem * 10> >" << std::endl;
82 return 1;
83 }
84
85 if (0 != test::map_test
86 < GetMapContainer<stable_vector<std::pair<int, int> > >::apply<int>::map_type
87 , MyStdMap
88 , GetMapContainer<stable_vector<std::pair<int, int> > >::apply<int>::multimap_type
89 , MyStdMultiMap>()) {
90 std::cout << "Error in map_test<stable_vector<std::pair<int, int> > >" << std::endl;
91 return 1;
92 }
93
94
95 if (0 != test::map_test
96 < GetMapContainer<deque<std::pair<int, int> > >::apply<int>::map_type
97 , MyStdMap
98 , GetMapContainer<deque<std::pair<int, int> > >::apply<int>::multimap_type
99 , MyStdMultiMap>()) {
100 std::cout << "Error in map_test<deque<std::pair<int, int> > >" << std::endl;
101 return 1;
102 }
20effc67
TL
103
104 if (0 != test::map_test
105 < GetMapContainer<devector<std::pair<int, int> > >::apply<int>::map_type
106 , MyStdMap
107 , GetMapContainer<devector<std::pair<int, int> > >::apply<int>::multimap_type
108 , MyStdMultiMap>()) {
109 std::cout << "Error in map_test<vector<std::pair<int, int> > >" << std::endl;
110 return 1;
111 }
112 }
113 {
114 using namespace boost::container;
115 using boost::container::dtl::is_same;
116
117 typedef flat_map<int, float, std::less<int>, small_vector<std::pair<int, float>, 10> > map_container_t;
118 typedef flat_multimap<int, float, std::less<int>, small_vector<std::pair<int, float>, 10> > multimap_container_t;
119 #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES)
120 BOOST_STATIC_ASSERT(( is_same<map_container_t, small_flat_map<int, float, 10> >::value ));
121 BOOST_STATIC_ASSERT(( is_same<multimap_container_t, small_flat_multimap<int, float, 10> >::value ));
122 #endif
123
124 BOOST_STATIC_ASSERT(( is_same<map_container_t, small_flat_map_of<int, float, 10>::type >::value ));
125 BOOST_STATIC_ASSERT(( is_same<multimap_container_t, small_flat_multimap_of<int, float, 10>::type >::value ));
92f5a8d4
TL
126 }
127
128 return 0;
129}