1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2004-2013. 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/detail/flat_tree.hpp>
11 #include <boost/container/small_vector.hpp>
12 #include <boost/container/stable_vector.hpp>
13 #include <boost/container/static_vector.hpp>
14
15 #include <iostream>
16
17 #include "movable_int.hpp"
18 #include "dummy_test_allocator.hpp"
19 #include <functional> //std::less
20
21 using namespace boost::container;
22
23 typedef boost::container::dtl::pair<test::movable_and_copyable_int, test::movable_and_copyable_int> pair_t;
24
25 namespace boost {
26 namespace container {
27
28 //Explicit instantiation to detect compilation errors
29
30 namespace dtl {
31
32 template class flat_tree
33 < pair_t
34 , select1st<test::movable_and_copyable_int>
35 , std::less<test::movable_and_copyable_int>
36 , test::simple_allocator<pair_t>
37 >;
38
39 template class flat_tree
40 < pair_t
41 , select1st<test::movable_and_copyable_int>
42 , std::less<test::movable_and_copyable_int>
43 , std::allocator<pair_t>
44 >;
45
46 template class flat_tree
47 < pair_t
48 , select1st<test::movable_and_copyable_int>
49 , std::less<test::movable_and_copyable_int>
50 , small_vector<pair_t, 10>
51 >;
52
53 template class flat_tree
54 < pair_t
55 , select1st<test::movable_and_copyable_int>
56 , std::less<test::movable_and_copyable_int>
57 , stable_vector<pair_t>
58 >;
59
60 template class flat_tree
61 < test::movable_and_copyable_int
62 , identity<test::movable_and_copyable_int>
63 , std::less<test::movable_and_copyable_int>
64 , test::simple_allocator<test::movable_and_copyable_int>
65 >;
66
67 template class flat_tree
68 < test::movable_and_copyable_int
69 , identity<test::movable_and_copyable_int>
70 , std::less<test::movable_and_copyable_int>
71 , std::allocator<test::movable_and_copyable_int>
72 >;
73
74 template class flat_tree
75 < test::movable_and_copyable_int
76 , identity<test::movable_and_copyable_int>
77 , std::less<test::movable_and_copyable_int>
78 , small_vector<test::movable_and_copyable_int, 10>
79 >;
80
81 template class flat_tree
82 < test::movable_and_copyable_int
83 , identity<test::movable_and_copyable_int>
84 , std::less<test::movable_and_copyable_int>
85 , stable_vector<test::movable_and_copyable_int>
86 >;
87
88 template class flat_tree
89 < test::movable_and_copyable_int
90 , identity<test::movable_and_copyable_int>
91 , std::less<test::movable_and_copyable_int>
92 , static_vector<test::movable_and_copyable_int, 10>
93 >;
94
95 } //dtl {
96 }} //boost::container
97
98 #if (__cplusplus > 201103L)
99 #include <vector>
100
101 namespace boost{
102 namespace container{
103 namespace dtl{
104
105 template class flat_tree
106 < test::movable_and_copyable_int
107 , identity<test::movable_and_copyable_int>
108 , std::less<test::movable_and_copyable_int>
109 , std::vector<test::movable_and_copyable_int>
110 >;
111
112 template class flat_tree
113 < pair_t
114 , select1st<test::movable_and_copyable_int>
115 , std::less<test::movable_and_copyable_int>
116 , std::vector<pair_t>
117 >;
118
119 } //dtl {
120 }} //boost::container
121
122 #endif
123
main()124 int main ()
125 {
126 ////////////////////////////////////
127 // has_trivial_destructor_after_move testing
128 ////////////////////////////////////
129 // default
130 {
131 typedef boost::container::dtl::flat_tree<int, boost::container::dtl::identity<int>,
132 std::less<int>, void> tree;
133 typedef tree::container_type container_type;
134 typedef tree::key_compare key_compare;
135 if (boost::has_trivial_destructor_after_move<tree>::value !=
136 boost::has_trivial_destructor_after_move<container_type>::value &&
137 boost::has_trivial_destructor_after_move<key_compare>::value) {
138 std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
139 return 1;
140 }
141 }
142 // std::allocator
143 {
144 typedef boost::container::dtl::flat_tree<int, boost::container::dtl::identity<int>,
145 std::less<int>, std::allocator<int> > tree;
146 typedef tree::container_type container_type;
147 typedef tree::key_compare key_compare;
148 if (boost::has_trivial_destructor_after_move<tree>::value !=
149 boost::has_trivial_destructor_after_move<container_type>::value &&
150 boost::has_trivial_destructor_after_move<key_compare>::value) {
151 std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
152 return 1;
153 }
154 }
155
156 return 0;
157 }
158