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_set.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> |
15 | #include <boost/container/deque.hpp> |
16 | #include <boost/container/devector.hpp> |
17 | |
18 | #include <boost/container/detail/container_or_allocator_rebind.hpp> |
19 | |
20 | #include "set_test.hpp" |
21 | #include <set> |
22 | |
23 | using namespace boost::container; |
24 | |
25 | template<class VoidAllocatorOrContainer> |
26 | struct GetSetContainer |
27 | { |
28 | template<class ValueType> |
29 | struct apply |
30 | { |
31 | typedef flat_set < ValueType |
32 | , std::less<ValueType> |
33 | , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, ValueType>::type |
34 | > set_type; |
35 | |
36 | typedef flat_multiset < ValueType |
37 | , std::less<ValueType> |
38 | , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, ValueType>::type |
39 | > multiset_type; |
40 | }; |
41 | }; |
42 | |
43 | int main() |
44 | { |
45 | using namespace boost::container::test; |
46 | |
47 | //////////////////////////////////// |
48 | // Testing sequence container implementations |
49 | //////////////////////////////////// |
50 | { |
51 | typedef std::set<int> MyStdSet; |
52 | typedef std::multiset<int> MyStdMultiSet; |
53 | |
54 | if (0 != test::set_test |
55 | < GetSetContainer<vector<int> >::apply<int>::set_type |
56 | , MyStdSet |
57 | , GetSetContainer<vector<int> >::apply<int>::multiset_type |
58 | , MyStdMultiSet>()) { |
59 | std::cout << "Error in set_test<vector<int> >" << std::endl; |
60 | return 1; |
61 | } |
62 | |
63 | if (0 != test::set_test |
64 | < GetSetContainer<small_vector<int, 7> >::apply<int>::set_type |
65 | , MyStdSet |
66 | , GetSetContainer<small_vector<int, 7> >::apply<int>::multiset_type |
67 | , MyStdMultiSet>()) { |
68 | std::cout << "Error in set_test<small_vector<int, 7> >" << std::endl; |
69 | return 1; |
70 | } |
71 | |
72 | if (0 != test::set_test |
73 | < GetSetContainer<static_vector<int, MaxElem * 10> >::apply<int>::set_type |
74 | , MyStdSet |
75 | , GetSetContainer<static_vector<int, MaxElem * 10> >::apply<int>::multiset_type |
76 | , MyStdMultiSet>()) { |
77 | std::cout << "Error in set_test<static_vector<int, MaxElem * 10> >" << std::endl; |
78 | return 1; |
79 | } |
80 | |
81 | if (0 != test::set_test |
82 | < GetSetContainer<stable_vector<int> >::apply<int>::set_type |
83 | , MyStdSet |
84 | , GetSetContainer<stable_vector<int> >::apply<int>::multiset_type |
85 | , MyStdMultiSet>()) { |
86 | std::cout << "Error in set_test<stable_vector<int> >" << std::endl; |
87 | return 1; |
88 | } |
89 | |
90 | |
91 | if (0 != test::set_test |
92 | < GetSetContainer<deque<int> >::apply<int>::set_type |
93 | , MyStdSet |
94 | , GetSetContainer<deque<int> >::apply<int>::multiset_type |
95 | , MyStdMultiSet>()) { |
96 | std::cout << "Error in set_test<deque<int> >" << std::endl; |
97 | return 1; |
98 | } |
99 | if (0 != test::set_test |
100 | < GetSetContainer<devector<int> >::apply<int>::set_type |
101 | , MyStdSet |
102 | , GetSetContainer<devector<int> >::apply<int>::multiset_type |
103 | , MyStdMultiSet>()) { |
104 | std::cout << "Error in set_test<deque<int> >" << std::endl; |
105 | return 1; |
106 | } |
107 | } |
108 | { |
109 | using namespace boost::container; |
110 | using boost::container::dtl::is_same; |
111 | |
112 | typedef flat_set<int, std::less<int>, small_vector<int, 10> > set_container_t; |
113 | typedef flat_multiset<int, std::less<int>, small_vector<int, 10> > multiset_container_t; |
114 | #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) |
115 | BOOST_CONTAINER_STATIC_ASSERT(( is_same<set_container_t, small_flat_set<int, 10> >::value )); |
116 | BOOST_CONTAINER_STATIC_ASSERT(( is_same<multiset_container_t, small_flat_multiset<int, 10> >::value )); |
117 | #endif |
118 | BOOST_CONTAINER_STATIC_ASSERT(( is_same<set_container_t, small_flat_set_of<int, 10>::type >::value )); |
119 | BOOST_CONTAINER_STATIC_ASSERT(( is_same<multiset_container_t, small_flat_multiset_of<int, 10>::type >::value )); |
120 | } |
121 | |
122 | return 0; |
123 | } |
124 | |