1 ////////////////////////////////////////
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)
7 // See http://www.boost.org/libs/container for documentation.
9 ////////////////////////////////////////
11 #ifndef BOOST_CONTAINER_TEST_SET_TEST_HEADER
12 #define BOOST_CONTAINER_TEST_SET_TEST_HEADER
14 #include <boost/container/detail/config_begin.hpp>
15 #include "check_equal_containers.hpp"
16 #include "print_container.hpp"
17 #include "movable_int.hpp"
18 #include <boost/move/utility_core.hpp>
19 #include <boost/move/iterator.hpp>
20 #include <boost/move/make_unique.hpp>
22 #if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
23 #pragma GCC diagnostic push
24 #pragma GCC diagnostic ignored "-Wunused-result"
27 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME rebalance
28 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace test {
29 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
30 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0
31 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0
32 #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
34 //#pragma GCC diagnostic ignored "-Wunused-result"
35 #if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
36 #pragma GCC diagnostic pop
44 void set_test_rebalanceable(C &, boost::container::dtl::false_type)
48 void set_test_rebalanceable(C &c, boost::container::dtl::true_type)
53 template<class MyBoostSet
55 ,class MyBoostMultiSet
57 int set_test_copyable(boost::container::dtl::false_type)
60 const int MaxElem = 50;
62 template<class MyBoostSet
64 ,class MyBoostMultiSet
66 int set_test_copyable(boost::container::dtl::true_type)
68 typedef typename MyBoostSet::value_type IntType;
70 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset = ::boost::movelib::make_unique<MyBoostSet>();
71 ::boost::movelib::unique_ptr<MyStdSet> const pstdset = ::boost::movelib::make_unique<MyStdSet>();
72 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset = ::boost::movelib::make_unique<MyBoostMultiSet>();
73 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset = ::boost::movelib::make_unique<MyStdMultiSet>();
75 MyBoostSet &boostset = *pboostset;
76 MyStdSet &stdset = *pstdset;
77 MyBoostMultiSet &boostmultiset = *pboostmultiset;
78 MyStdMultiSet &stdmultiset = *pstdmultiset;
80 //Just to test move aware catch conversions
81 boostset.insert(boostset.cbegin(), boostset.cend());
82 boostmultiset.insert(boostmultiset.cbegin(), boostmultiset.cend());
83 boostset.insert(boostset.begin(), boostset.end());
84 boostmultiset.insert(boostmultiset.begin(), boostmultiset.end());
86 for(int i = 0; i < MaxElem; ++i){
88 boostset.insert(boost::move(move_me));
91 boostmultiset.insert(boost::move(move_me2));
92 stdmultiset.insert(i);
94 if(!CheckEqualContainers(boostset, stdset)) return 1;
95 if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
98 //Now, test copy constructor
99 MyBoostSet boostsetcopy(boostset);
100 MyStdSet stdsetcopy(stdset);
102 if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
105 MyBoostMultiSet boostmsetcopy(boostmultiset);
106 MyStdMultiSet stdmsetcopy(stdmultiset);
108 if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
112 boostsetcopy =boostset;
115 if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
118 boostmsetcopy = boostmultiset;
119 stdmsetcopy = stdmultiset;
121 if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
125 //Now, test copy constructor with allocator
126 MyBoostSet boostsetcopy(boostset, typename MyBoostSet::allocator_type());
127 MyStdSet stdsetcopy(stdset);
129 if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
132 MyBoostMultiSet boostmsetcopy(boostmultiset, typename MyBoostSet::allocator_type());
133 MyStdMultiSet stdmsetcopy(stdmultiset);
135 if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
142 template<class MyBoostSet
144 ,class MyBoostMultiSet
145 ,class MyStdMultiSet>
148 typedef typename MyBoostSet::value_type IntType;
150 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset = ::boost::movelib::make_unique<MyBoostSet>();
151 ::boost::movelib::unique_ptr<MyStdSet> const pstdset = ::boost::movelib::make_unique<MyStdSet>();
152 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset = ::boost::movelib::make_unique<MyBoostMultiSet>();
153 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset = ::boost::movelib::make_unique<MyStdMultiSet>();
155 MyBoostSet &boostset = *pboostset;
156 MyStdSet &stdset = *pstdset;
157 MyBoostMultiSet &boostmultiset = *pboostmultiset;
158 MyStdMultiSet &stdmultiset = *pstdmultiset;
160 //Test construction from a range
161 { //Set(beg, end, compare)
162 IntType aux_vect[50];
163 for(int i = 0; i < 50; ++i){
164 IntType move_me(i/2);
165 aux_vect[i] = boost::move(move_me);
168 for(int i = 0; i < 50; ++i){
171 IntType aux_vect3[50];
172 for(int i = 0; i < 50; ++i){
173 IntType move_me(i/2);
174 aux_vect3[i] = boost::move(move_me);
176 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
177 (boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0]+50), typename MyBoostSet::key_compare());
178 ::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>(&aux_vect2[0], &aux_vect2[0]+50);
179 if(!test::CheckEqualContainers(*pboostset2, *pstdset2)) return 1;
180 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>
181 (boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0]+50), typename MyBoostMultiSet::key_compare());
182 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset2 = ::boost::movelib::make_unique<MyStdMultiSet>(&aux_vect2[0], &aux_vect2[0]+50);
183 if(!test::CheckEqualContainers(*pboostmultiset2, *pstdmultiset2)) return 1;
185 { //Set(beg, end, alloc)
186 IntType aux_vect[50];
187 for(int i = 0; i < 50; ++i){
188 IntType move_me(i/2);
189 aux_vect[i] = boost::move(move_me);
192 for(int i = 0; i < 50; ++i){
195 IntType aux_vect3[50];
196 for(int i = 0; i < 50; ++i){
197 IntType move_me(i/2);
198 aux_vect3[i] = boost::move(move_me);
200 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
201 (boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0]+50), typename MyBoostSet::allocator_type());
202 ::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>(&aux_vect2[0], &aux_vect2[0]+50);
203 if(!test::CheckEqualContainers(*pboostset2, *pstdset2)) return 1;
204 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>
205 (boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0]+50), typename MyBoostMultiSet::allocator_type());
206 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset2 = ::boost::movelib::make_unique<MyStdMultiSet>(&aux_vect2[0], &aux_vect2[0]+50);
207 if(!test::CheckEqualContainers(*pboostmultiset2, *pstdmultiset2)) return 1;
210 IntType aux_vect[50];
211 for(int i = 0; i < 50; ++i){
212 IntType move_me(i/2);
213 aux_vect[i] = boost::move(move_me);
216 for(int i = 0; i < 50; ++i){
219 IntType aux_vect3[50];
220 for(int i = 0; i < 50; ++i){
221 IntType move_me(i/2);
222 aux_vect3[i] = boost::move(move_me);
225 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
226 ( boost::make_move_iterator(&aux_vect[0])
227 , boost::make_move_iterator(aux_vect + 50));
228 ::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>
229 (&aux_vect2[0], &aux_vect2[0] + 50);
230 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>
231 ( boost::make_move_iterator(&aux_vect3[0])
232 , boost::make_move_iterator(aux_vect3 + 50));
233 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset2 = ::boost::movelib::make_unique<MyStdMultiSet>
234 (&aux_vect2[0], &aux_vect2[0] + 50);
236 MyBoostSet &boostset2 = *pboostset2;
237 MyStdSet &stdset2 = *pstdset2;
238 MyBoostMultiSet &boostmultiset2 = *pboostmultiset2;
239 MyStdMultiSet &stdmultiset2 = *pstdmultiset2;
241 if(!CheckEqualContainers(boostset2, stdset2)){
242 std::cout << "Error in construct<MyBoostSet>(MyBoostSet2)" << std::endl;
245 if(!CheckEqualContainers(boostmultiset2, stdmultiset2)){
246 std::cout << "Error in construct<MyBoostMultiSet>(MyBoostMultiSet2)" << std::endl;
250 //ordered range insertion
251 for(int i = 0; i < 50; ++i){
253 aux_vect[i] = boost::move(move_me);
256 for(int i = 0; i < 50; ++i){
260 for(int i = 0; i < 50; ++i){
262 aux_vect3[i] = boost::move(move_me);
265 //some comparison operators
266 if(!(boostset2 == boostset2))
268 if(boostset2 != boostset2)
270 if(boostset2 < boostset2)
272 if(boostset2 > boostset2)
274 if(!(boostset2 <= boostset2))
276 if(!(boostset2 >= boostset2))
279 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset3 = ::boost::movelib::make_unique<MyBoostSet>
280 ( ordered_unique_range
281 , boost::make_move_iterator(&aux_vect[0])
282 , boost::make_move_iterator(&aux_vect[0] + 50));
283 ::boost::movelib::unique_ptr<MyStdSet> const pstdset3 = ::boost::movelib::make_unique<MyStdSet>
284 (&aux_vect2[0], &aux_vect2[0] + 50);
285 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset3 = ::boost::movelib::make_unique<MyBoostMultiSet>
287 , boost::make_move_iterator(&aux_vect3[0])
288 , boost::make_move_iterator(aux_vect3 + 50));
289 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset3 = ::boost::movelib::make_unique<MyStdMultiSet>
290 (&aux_vect2[0], &aux_vect2[0] + 50);
292 MyBoostSet &boostset3 = *pboostset3;
293 MyStdSet &stdset3 = *pstdset3;
294 MyBoostMultiSet &boostmultiset3 = *pboostmultiset3;
295 MyStdMultiSet &stdmultiset3 = *pstdmultiset3;
297 if(!CheckEqualContainers(boostset3, stdset3)){
298 std::cout << "Error in construct<MyBoostSet>(MyBoostSet3)" << std::endl;
301 if(!CheckEqualContainers(boostmultiset3, stdmultiset3)){
302 std::cout << "Error in construct<MyBoostMultiSet>(MyBoostMultiSet3)" << std::endl;
307 for(int i = 0; i < MaxElem; ++i){
309 boostset.insert(boost::move(move_me));
311 boostset.insert(IntType(i));
314 boostmultiset.insert(boost::move(move_me2));
315 stdmultiset.insert(i);
316 boostmultiset.insert(IntType(i));
317 stdmultiset.insert(i);
320 if(!CheckEqualContainers(boostset, stdset)){
321 std::cout << "Error in boostset.insert(boost::move(move_me)" << std::endl;
325 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
326 std::cout << "Error in boostmultiset.insert(boost::move(move_me)" << std::endl;
330 typename MyBoostSet::iterator it = boostset.begin();
331 typename MyBoostSet::const_iterator cit = it;
334 boostset.erase(boostset.begin());
335 stdset.erase(stdset.begin());
336 boostmultiset.erase(boostmultiset.begin());
337 stdmultiset.erase(stdmultiset.begin());
338 if(!CheckEqualContainers(boostset, stdset)){
339 std::cout << "Error in boostset.erase(boostset.begin())" << std::endl;
342 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
343 std::cout << "Error in boostmultiset.erase(boostmultiset.begin())" << std::endl;
347 boostset.erase(boostset.begin());
348 stdset.erase(stdset.begin());
349 boostmultiset.erase(boostmultiset.begin());
350 stdmultiset.erase(stdmultiset.begin());
351 if(!CheckEqualContainers(boostset, stdset)){
352 std::cout << "Error in boostset.erase(boostset.begin())" << std::endl;
355 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
356 std::cout << "Error in boostmultiset.erase(boostmultiset.begin())" << std::endl;
362 MyBoostSet tmpboosteset2;
364 MyBoostMultiSet tmpboostemultiset2;
365 MyStdMultiSet tmpstdmultiset2;
366 boostset.swap(tmpboosteset2);
367 stdset.swap(tmpstdset2);
368 boostmultiset.swap(tmpboostemultiset2);
369 stdmultiset.swap(tmpstdmultiset2);
370 boostset.swap(tmpboosteset2);
371 stdset.swap(tmpstdset2);
372 boostmultiset.swap(tmpboostemultiset2);
373 stdmultiset.swap(tmpstdmultiset2);
374 if(!CheckEqualContainers(boostset, stdset)){
375 std::cout << "Error in boostset.swap(tmpboosteset2)" << std::endl;
378 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
379 std::cout << "Error in boostmultiset.swap(tmpboostemultiset2)" << std::endl;
384 //move constructor/assignment
386 MyBoostSet tmpboosteset2(boost::move(boostset));
387 if(!CheckEqualContainers(tmpboosteset2, stdset)){
388 std::cout << "Error in boostset move constructor " << std::endl;
391 MyBoostMultiSet tmpboostemultiset2(boost::move(boostmultiset));
392 if(!CheckEqualContainers(tmpboostemultiset2, stdmultiset)){
393 std::cout << "Error in boostmultiset move constructor " << std::endl;
397 boostset = boost::move(tmpboosteset2);
398 if(!CheckEqualContainers(boostset, stdset)){
399 std::cout << "Error in boostset move assignment" << std::endl;
402 boostmultiset = boost::move(tmpboostemultiset2);
403 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
404 std::cout << "Error in boostmultiset move assignment" << std::endl;
408 //Insertion from other container
411 IntType aux_vect[50];
412 for(int i = 0; i < 50; ++i){
414 aux_vect[i] = boost::move(move_me);
417 for(int i = 0; i < 50; ++i){
420 IntType aux_vect3[50];
421 for(int i = 0; i < 50; ++i){
423 aux_vect3[i] = boost::move(move_me);
426 boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
427 stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
428 if(!CheckEqualContainers(boostset, stdset)){
429 std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect3[0])..." << std::endl;
432 boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
433 stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
434 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
435 std::cout << "Error in boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), ..." << std::endl;
439 for(int i = 0, j = static_cast<int>(boostset.size()); i < j; ++i){
441 boostset.erase(erase_me);
443 boostmultiset.erase(erase_me);
444 stdmultiset.erase(i);
445 if(!CheckEqualContainers(boostset, stdset)){
446 std::cout << "Error in boostset.erase(erase_me)" << boostset.size() << " " << stdset.size() << std::endl;
449 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
450 std::cout << "Error in boostmultiset.erase(erase_me)" << std::endl;
456 IntType aux_vect[50];
457 for(int i = 0; i < 50; ++i){
459 aux_vect[i] = boost::move(move_me);
462 for(int i = 0; i < 50; ++i){
465 IntType aux_vect3[50];
466 for(int i = 0; i < 50; ++i){
468 aux_vect3[i] = boost::move(move_me);
471 IntType aux_vect4[50];
472 for(int i = 0; i < 50; ++i){
474 aux_vect4[i] = boost::move(move_me);
477 IntType aux_vect5[50];
478 for(int i = 0; i < 50; ++i){
480 aux_vect5[i] = boost::move(move_me);
483 boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
484 boostset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + 50));
485 stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
486 stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
487 if(!CheckEqualContainers(boostset, stdset)){
488 std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect3[0])..." << std::endl;
491 boostmultiset.insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(&aux_vect4[0] + 50));
492 boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(&aux_vect5[0] + 50));
493 stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
494 stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
495 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
496 std::cout << "Error in boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0])..." << std::endl;
500 boostset.erase(*boostset.begin());
501 stdset.erase(*stdset.begin());
502 if(!CheckEqualContainers(boostset, stdset)){
503 std::cout << "Error in boostset.erase(*boostset.begin())" << std::endl;
506 boostmultiset.erase(*boostmultiset.begin());
507 stdmultiset.erase(*stdmultiset.begin());
508 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
509 std::cout << "Error in boostmultiset.erase(*boostmultiset.begin())" << std::endl;
514 for(int i = 0; i < MaxElem; ++i){
516 boostset.insert(boost::move(move_me));
519 boostmultiset.insert(boost::move(move_me2));
520 stdmultiset.insert(i);
523 if(!CheckEqualContainers(boostset, stdset)){
524 std::cout << "Error in boostset.insert(boost::move(move_me)) try 2" << std::endl;
527 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
528 std::cout << "Error in boostmultiset.insert(boost::move(move_me2)) try 2" << std::endl;
532 for(int i = 0; i < MaxElem; ++i){
535 boostset.insert(boostset.begin(), boost::move(move_me));
536 stdset.insert(stdset.begin(), i);
537 //PrintContainers(boostset, stdset);
539 boostmultiset.insert(boostmultiset.begin(), boost::move(move_me2));
540 stdmultiset.insert(stdmultiset.begin(), i);
541 //PrintContainers(boostmultiset, stdmultiset);
542 if(!CheckEqualContainers(boostset, stdset)){
543 std::cout << "Error in boostset.insert(boostset.begin(), boost::move(move_me))" << std::endl;
546 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
547 std::cout << "Error in boostmultiset.insert(boostmultiset.begin(), boost::move(move_me2))" << std::endl;
552 boostset.insert(boostset.end(), boost::move(move_me3));
553 stdset.insert(stdset.end(), i);
555 boostmultiset.insert(boostmultiset.end(), boost::move(move_me4));
556 stdmultiset.insert(stdmultiset.end(), i);
557 if(!CheckEqualContainers(boostset, stdset)){
558 std::cout << "Error in boostset.insert(boostset.end(), boost::move(move_me3))" << std::endl;
561 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
562 std::cout << "Error in boostmultiset.insert(boostmultiset.end(), boost::move(move_me4))" << std::endl;
568 boostset.insert(boostset.upper_bound(move_me), boost::move(move_me));
569 stdset.insert(stdset.upper_bound(i), i);
570 //PrintContainers(boostset, stdset);
572 boostmultiset.insert(boostmultiset.upper_bound(move_me2), boost::move(move_me2));
573 stdmultiset.insert(stdmultiset.upper_bound(i), i);
574 //PrintContainers(boostmultiset, stdmultiset);
575 if(!CheckEqualContainers(boostset, stdset)){
576 std::cout << "Error in boostset.insert(boostset.upper_bound(move_me), boost::move(move_me))" << std::endl;
579 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
580 std::cout << "Error in boostmultiset.insert(boostmultiset.upper_bound(move_me2), boost::move(move_me2))" << std::endl;
588 boostset.insert(boostset.lower_bound(move_me), boost::move(move_me2));
589 stdset.insert(stdset.lower_bound(i), i);
590 //PrintContainers(boostset, stdset);
592 boostmultiset.insert(boostmultiset.lower_bound(move_me2), boost::move(move_me2));
593 stdmultiset.insert(stdmultiset.lower_bound(i), i);
594 //PrintContainers(boostmultiset, stdmultiset);
595 if(!CheckEqualContainers(boostset, stdset)){
596 std::cout << "Error in boostset.insert(boostset.lower_bound(move_me), boost::move(move_me2))" << std::endl;
599 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
600 std::cout << "Error in boostmultiset.insert(boostmultiset.lower_bound(move_me2), boost::move(move_me2))" << std::endl;
603 set_test_rebalanceable(boostset
604 , dtl::bool_<has_member_function_callable_with_rebalance<MyBoostSet>::value>());
605 if(!CheckEqualContainers(boostset, stdset)){
606 std::cout << "Error in boostset.rebalance()" << std::endl;
609 set_test_rebalanceable(boostmultiset
610 , dtl::bool_<has_member_function_callable_with_rebalance<MyBoostMultiSet>::value>());
611 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
612 std::cout << "Error in boostmultiset.rebalance()" << std::endl;
618 //Compare count with std containers
619 for(int i = 0; i < MaxElem; ++i){
621 if(boostset.count(k) != stdset.count(i)){
625 if(boostset.contains(k) != (stdset.find(i) != stdset.end())){
629 if(boostmultiset.count(k) != stdmultiset.count(i)){
633 if(boostmultiset.contains(k) != (stdmultiset.find(i) != stdmultiset.end())){
638 //Compare find/lower_bound/upper_bound in set
640 typename MyBoostSet::iterator bs_b = boostset.begin();
641 typename MyBoostSet::iterator bs_e = boostset.end();
642 typename MyStdSet::iterator ss_b = stdset.begin();
647 typename MyBoostSet::iterator bs_i;
648 typename MyStdSet::iterator ss_i;
650 bs_i = boostset.find(*bs_b);
651 ss_i = stdset.find(*ss_b);
652 if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
656 bs_i = boostset.lower_bound(*bs_b);
657 ss_i = stdset.lower_bound(*ss_b);
658 if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
662 bs_i = boostset.upper_bound(*bs_b);
663 ss_i = stdset.upper_bound(*ss_b);
664 if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
668 std::pair<typename MyBoostSet::iterator
669 ,typename MyBoostSet::iterator> bs_ip;
670 std::pair<typename MyStdSet::iterator
671 ,typename MyStdSet::iterator> ss_ip;
672 bs_ip = boostset.equal_range(*bs_b);
673 ss_ip = stdset.equal_range(*ss_b);
674 if(!CheckEqualIt(bs_ip.first, ss_ip.first, boostset, stdset)){
677 if(!CheckEqualIt(bs_ip.second, ss_ip.second, boostset, stdset)){
684 //Compare find/lower_bound/upper_bound in multiset
686 typename MyBoostMultiSet::iterator bm_b = boostmultiset.begin();
687 typename MyBoostMultiSet::iterator bm_e = boostmultiset.end();
688 typename MyStdMultiSet::iterator sm_b = stdmultiset.begin();
691 typename MyBoostMultiSet::iterator bm_i;
692 typename MyStdMultiSet::iterator sm_i;
694 bm_i = boostmultiset.find(*bm_b);
695 sm_i = stdmultiset.find(*sm_b);
696 if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
700 bm_i = boostmultiset.lower_bound(*bm_b);
701 sm_i = stdmultiset.lower_bound(*sm_b);
702 if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
706 bm_i = boostmultiset.upper_bound(*bm_b);
707 sm_i = stdmultiset.upper_bound(*sm_b);
708 if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
712 std::pair<typename MyBoostMultiSet::iterator
713 ,typename MyBoostMultiSet::iterator> bm_ip;
714 std::pair<typename MyStdMultiSet::iterator
715 ,typename MyStdMultiSet::iterator> sm_ip;
716 bm_ip = boostmultiset.equal_range(*bm_b);
717 sm_ip = stdmultiset.equal_range(*sm_b);
718 if(!CheckEqualIt(bm_ip.first, sm_ip.first, boostmultiset, stdmultiset)){
721 if(!CheckEqualIt(bm_ip.second, sm_ip.second, boostmultiset, stdmultiset)){
729 //Now do count exercise
730 boostset.erase(boostset.begin(), boostset.end());
731 boostmultiset.erase(boostmultiset.begin(), boostmultiset.end());
733 boostmultiset.clear();
735 for(int j = 0; j < 3; ++j)
736 for(int i = 0; i < 100; ++i){
738 boostset.insert(boost::move(move_me));
740 boostmultiset.insert(boost::move(move_me2));
742 if(boostset.count(count_me) != typename MyBoostMultiSet::size_type(1)){
743 std::cout << "Error in boostset.count(count_me)" << std::endl;
746 if(boostmultiset.count(count_me) != typename MyBoostMultiSet::size_type(j+1)){
747 std::cout << "Error in boostmultiset.count(count_me)" << std::endl;
753 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>();
754 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>();
756 MyBoostSet &boostset2 = *pboostset2;
757 MyBoostMultiSet &boostmultiset2 = *pboostmultiset2;
761 boostmultiset.clear();
762 boostmultiset2.clear();
767 IntType aux_vect[(std::size_t)MaxElem];
768 for(int i = 0; i < MaxElem; ++i){
772 IntType aux_vect2[(std::size_t)MaxElem];
773 for(int i = 0; i < MaxElem; ++i){
774 aux_vect2[i] = MaxElem/2+i;
776 IntType aux_vect3[(std::size_t)MaxElem];
777 for(int i = 0; i < MaxElem; ++i){
778 aux_vect3[i] = MaxElem*2/2+i;
780 boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + MaxElem));
781 boostset2.insert(boost::make_move_iterator(&aux_vect2[0]), boost::make_move_iterator(&aux_vect2[0] + MaxElem));
782 boostmultiset2.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + MaxElem));
784 for(int i = 0; i < MaxElem; ++i){
787 for(int i = 0; i < MaxElem; ++i){
788 stdset.insert(MaxElem/2+i);
791 boostset.merge(boost::move(boostset2));
792 if(!CheckEqualContainers(boostset, stdset)) return 1;
794 for(int i = 0; i < MaxElem; ++i){
795 stdset.insert(MaxElem*2/2+i);
798 boostset.merge(boost::move(boostmultiset2));
799 if(!CheckEqualContainers(boostset, stdset)) return 1;
803 boostmultiset.clear();
804 boostmultiset2.clear();
808 IntType aux_vect[(std::size_t)MaxElem];
809 for(int i = 0; i < MaxElem; ++i){
813 IntType aux_vect2[(std::size_t)MaxElem];
814 for(int i = 0; i < MaxElem; ++i){
815 aux_vect2[i] = MaxElem/2+i;
817 IntType aux_vect3[(std::size_t)MaxElem];
818 for(int i = 0; i < MaxElem; ++i){
819 aux_vect3[i] = MaxElem*2/2+i;
821 boostmultiset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + MaxElem));
822 boostmultiset2.insert(boost::make_move_iterator(&aux_vect2[0]), boost::make_move_iterator(&aux_vect2[0] + MaxElem));
823 boostset2.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + MaxElem));
825 for(int i = 0; i < MaxElem; ++i){
826 stdmultiset.insert(i);
828 for(int i = 0; i < MaxElem; ++i){
829 stdmultiset.insert(MaxElem/2+i);
831 boostmultiset.merge(boost::move(boostmultiset2));
832 if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
834 for(int i = 0; i < MaxElem; ++i){
835 stdmultiset.insert(MaxElem*2/2+i);
838 boostmultiset.merge(boost::move(boostset2));
839 if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
842 if(set_test_copyable<MyBoostSet, MyStdSet, MyBoostMultiSet, MyStdMultiSet>
843 (dtl::bool_<boost::container::test::is_copyable<IntType>::value>())){
850 template<typename SetType>
851 bool test_set_methods_with_initializer_list_as_argument_for()
853 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
854 std::initializer_list<int> il = { 1, 2, 3, 4, 5, 5 };
855 std::initializer_list<int> ilu = { 1, 2, 3, 4, 5 };
856 SetType expected(il.begin(), il.end());
857 SetType expectedu(ilu.begin(), ilu.end());
863 SetType sila(il, typename SetType::allocator_type());
864 if (sila != expected)
867 SetType silca(il, typename SetType::key_compare(), typename SetType::allocator_type());
868 if (silca != expected)
871 SetType sil_ordered(ordered_unique_range, ilu);
872 if (sil_ordered != expectedu)
875 SetType sil_assign = { 99, 100, 101, 102, 103, 104, 105 };
877 if (sil_assign != expected)
891 template<typename SetType, typename MultisetType>
892 bool instantiate_constructors()
895 typedef typename SetType::value_type value_type;
896 typename SetType::key_compare comp;
897 typename SetType::allocator_type a;
906 SetType s0(&value, &value);
907 SetType s1(&value, &value ,comp);
908 SetType s2(&value, &value ,a);
909 SetType s3(&value, &value ,comp, a);
911 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
914 SetType s1({ 0 },comp);
916 SetType s3({ 0 },comp, a);
919 std::initializer_list<value_type> il{0};
920 SetType s0(ordered_unique_range, il);
921 SetType s1(ordered_unique_range, il,comp);
922 SetType s3(ordered_unique_range, il,comp, a);
926 SetType s0(ordered_unique_range, &value, &value);
927 SetType s1(ordered_unique_range, &value, &value ,comp);
928 SetType s2(ordered_unique_range, &value, &value ,comp, a);
933 typedef typename MultisetType::value_type value_type;
934 typename MultisetType::key_compare comp;
935 typename MultisetType::allocator_type a;
939 MultisetType s1(comp);
941 MultisetType s3(comp, a);
944 MultisetType s0(&value, &value);
945 MultisetType s1(&value, &value ,comp);
946 MultisetType s2(&value, &value ,a);
947 MultisetType s3(&value, &value ,comp, a);
949 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
951 MultisetType s0({ 0 });
952 MultisetType s1({ 0 },comp);
953 MultisetType s2({ 0 },a);
954 MultisetType s3({ 0 },comp, a);
957 std::initializer_list<value_type>il{0};
958 MultisetType s0(ordered_range, il);
959 MultisetType s1(ordered_range, il,comp);
960 MultisetType s3(ordered_range, il,comp, a);
964 MultisetType s0(ordered_range, &value, &value);
965 MultisetType s1(ordered_range, &value, &value ,comp);
966 MultisetType s2(ordered_range, &value, &value ,comp, a);
973 } //namespace container {
976 #include <boost/container/detail/config_end.hpp>