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 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME rebalance
23 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace test {
24 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
25 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0
26 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0
27 #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
34 void set_test_rebalanceable(C &, boost::container::dtl::false_type)
38 void set_test_rebalanceable(C &c, boost::container::dtl::true_type)
43 template<class MyBoostSet
45 ,class MyBoostMultiSet
47 int set_test_copyable(boost::container::dtl::false_type)
50 const int MaxElem = 50;
52 template<class MyBoostSet
54 ,class MyBoostMultiSet
56 int set_test_copyable(boost::container::dtl::true_type)
58 typedef typename MyBoostSet::value_type IntType;
60 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset = ::boost::movelib::make_unique<MyBoostSet>();
61 ::boost::movelib::unique_ptr<MyStdSet> const pstdset = ::boost::movelib::make_unique<MyStdSet>();
62 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset = ::boost::movelib::make_unique<MyBoostMultiSet>();
63 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset = ::boost::movelib::make_unique<MyStdMultiSet>();
65 MyBoostSet &boostset = *pboostset;
66 MyStdSet &stdset = *pstdset;
67 MyBoostMultiSet &boostmultiset = *pboostmultiset;
68 MyStdMultiSet &stdmultiset = *pstdmultiset;
70 //Just to test move aware catch conversions
71 boostset.insert(boostset.cbegin(), boostset.cend());
72 boostmultiset.insert(boostmultiset.cbegin(), boostmultiset.cend());
73 boostset.insert(boostset.begin(), boostset.end());
74 boostmultiset.insert(boostmultiset.begin(), boostmultiset.end());
76 for(int i = 0; i < MaxElem; ++i){
78 boostset.insert(boost::move(move_me));
81 boostmultiset.insert(boost::move(move_me2));
82 stdmultiset.insert(i);
84 if(!CheckEqualContainers(boostset, stdset)) return 1;
85 if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
88 //Now, test copy constructor
89 MyBoostSet boostsetcopy(boostset);
90 MyStdSet stdsetcopy(stdset);
92 if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
95 MyBoostMultiSet boostmsetcopy(boostmultiset);
96 MyStdMultiSet stdmsetcopy(stdmultiset);
98 if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
102 boostsetcopy =boostset;
105 if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
108 boostmsetcopy = boostmultiset;
109 stdmsetcopy = stdmultiset;
111 if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
115 //Now, test copy constructor with allocator
116 MyBoostSet boostsetcopy(boostset, typename MyBoostSet::allocator_type());
117 MyStdSet stdsetcopy(stdset);
119 if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
122 MyBoostMultiSet boostmsetcopy(boostmultiset, typename MyBoostSet::allocator_type());
123 MyStdMultiSet stdmsetcopy(stdmultiset);
125 if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
132 template<class MyBoostSet
134 ,class MyBoostMultiSet
135 ,class MyStdMultiSet>
138 typedef typename MyBoostSet::value_type IntType;
140 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset = ::boost::movelib::make_unique<MyBoostSet>();
141 ::boost::movelib::unique_ptr<MyStdSet> const pstdset = ::boost::movelib::make_unique<MyStdSet>();
142 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset = ::boost::movelib::make_unique<MyBoostMultiSet>();
143 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset = ::boost::movelib::make_unique<MyStdMultiSet>();
145 MyBoostSet &boostset = *pboostset;
146 MyStdSet &stdset = *pstdset;
147 MyBoostMultiSet &boostmultiset = *pboostmultiset;
148 MyStdMultiSet &stdmultiset = *pstdmultiset;
150 //Test construction from a range
151 { //Set(beg, end, compare)
152 IntType aux_vect[50];
153 for(int i = 0; i < 50; ++i){
154 IntType move_me(i/2);
155 aux_vect[i] = boost::move(move_me);
158 for(int i = 0; i < 50; ++i){
161 IntType aux_vect3[50];
162 for(int i = 0; i < 50; ++i){
163 IntType move_me(i/2);
164 aux_vect3[i] = boost::move(move_me);
166 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
167 (boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0]+50), typename MyBoostSet::key_compare());
168 ::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>(&aux_vect2[0], &aux_vect2[0]+50);
169 if(!test::CheckEqualContainers(*pboostset2, *pstdset2)) return 1;
170 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>
171 (boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0]+50), typename MyBoostMultiSet::key_compare());
172 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset2 = ::boost::movelib::make_unique<MyStdMultiSet>(&aux_vect2[0], &aux_vect2[0]+50);
173 if(!test::CheckEqualContainers(*pboostmultiset2, *pstdmultiset2)) return 1;
175 { //Set(beg, end, alloc)
176 IntType aux_vect[50];
177 for(int i = 0; i < 50; ++i){
178 IntType move_me(i/2);
179 aux_vect[i] = boost::move(move_me);
182 for(int i = 0; i < 50; ++i){
185 IntType aux_vect3[50];
186 for(int i = 0; i < 50; ++i){
187 IntType move_me(i/2);
188 aux_vect3[i] = boost::move(move_me);
190 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
191 (boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0]+50), typename MyBoostSet::allocator_type());
192 ::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>(&aux_vect2[0], &aux_vect2[0]+50);
193 if(!test::CheckEqualContainers(*pboostset2, *pstdset2)) return 1;
194 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>
195 (boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0]+50), typename MyBoostMultiSet::allocator_type());
196 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset2 = ::boost::movelib::make_unique<MyStdMultiSet>(&aux_vect2[0], &aux_vect2[0]+50);
197 if(!test::CheckEqualContainers(*pboostmultiset2, *pstdmultiset2)) return 1;
200 IntType aux_vect[50];
201 for(int i = 0; i < 50; ++i){
202 IntType move_me(i/2);
203 aux_vect[i] = boost::move(move_me);
206 for(int i = 0; i < 50; ++i){
209 IntType aux_vect3[50];
210 for(int i = 0; i < 50; ++i){
211 IntType move_me(i/2);
212 aux_vect3[i] = boost::move(move_me);
215 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
216 ( boost::make_move_iterator(&aux_vect[0])
217 , boost::make_move_iterator(aux_vect + 50));
218 ::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>
219 (&aux_vect2[0], &aux_vect2[0] + 50);
220 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>
221 ( boost::make_move_iterator(&aux_vect3[0])
222 , boost::make_move_iterator(aux_vect3 + 50));
223 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset2 = ::boost::movelib::make_unique<MyStdMultiSet>
224 (&aux_vect2[0], &aux_vect2[0] + 50);
226 MyBoostSet &boostset2 = *pboostset2;
227 MyStdSet &stdset2 = *pstdset2;
228 MyBoostMultiSet &boostmultiset2 = *pboostmultiset2;
229 MyStdMultiSet &stdmultiset2 = *pstdmultiset2;
231 if(!CheckEqualContainers(boostset2, stdset2)){
232 std::cout << "Error in construct<MyBoostSet>(MyBoostSet2)" << std::endl;
235 if(!CheckEqualContainers(boostmultiset2, stdmultiset2)){
236 std::cout << "Error in construct<MyBoostMultiSet>(MyBoostMultiSet2)" << std::endl;
240 //ordered range insertion
241 for(int i = 0; i < 50; ++i){
243 aux_vect[i] = boost::move(move_me);
246 for(int i = 0; i < 50; ++i){
250 for(int i = 0; i < 50; ++i){
252 aux_vect3[i] = boost::move(move_me);
255 //some comparison operators
256 if(!(boostset2 == boostset2))
258 if(boostset2 != boostset2)
260 if(boostset2 < boostset2)
262 if(boostset2 > boostset2)
264 if(!(boostset2 <= boostset2))
266 if(!(boostset2 >= boostset2))
269 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset3 = ::boost::movelib::make_unique<MyBoostSet>
270 ( ordered_unique_range
271 , boost::make_move_iterator(&aux_vect[0])
272 , boost::make_move_iterator(&aux_vect[0] + 50));
273 ::boost::movelib::unique_ptr<MyStdSet> const pstdset3 = ::boost::movelib::make_unique<MyStdSet>
274 (&aux_vect2[0], &aux_vect2[0] + 50);
275 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset3 = ::boost::movelib::make_unique<MyBoostMultiSet>
277 , boost::make_move_iterator(&aux_vect3[0])
278 , boost::make_move_iterator(aux_vect3 + 50));
279 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset3 = ::boost::movelib::make_unique<MyStdMultiSet>
280 (&aux_vect2[0], &aux_vect2[0] + 50);
282 MyBoostSet &boostset3 = *pboostset3;
283 MyStdSet &stdset3 = *pstdset3;
284 MyBoostMultiSet &boostmultiset3 = *pboostmultiset3;
285 MyStdMultiSet &stdmultiset3 = *pstdmultiset3;
287 if(!CheckEqualContainers(boostset3, stdset3)){
288 std::cout << "Error in construct<MyBoostSet>(MyBoostSet3)" << std::endl;
291 if(!CheckEqualContainers(boostmultiset3, stdmultiset3)){
292 std::cout << "Error in construct<MyBoostMultiSet>(MyBoostMultiSet3)" << std::endl;
297 for(int i = 0; i < MaxElem; ++i){
299 boostset.insert(boost::move(move_me));
301 boostset.insert(IntType(i));
304 boostmultiset.insert(boost::move(move_me2));
305 stdmultiset.insert(i);
306 boostmultiset.insert(IntType(i));
307 stdmultiset.insert(i);
310 if(!CheckEqualContainers(boostset, stdset)){
311 std::cout << "Error in boostset.insert(boost::move(move_me)" << std::endl;
315 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
316 std::cout << "Error in boostmultiset.insert(boost::move(move_me)" << std::endl;
320 typename MyBoostSet::iterator it = boostset.begin();
321 typename MyBoostSet::const_iterator cit = it;
324 boostset.erase(boostset.begin());
325 stdset.erase(stdset.begin());
326 boostmultiset.erase(boostmultiset.begin());
327 stdmultiset.erase(stdmultiset.begin());
328 if(!CheckEqualContainers(boostset, stdset)){
329 std::cout << "Error in boostset.erase(boostset.begin())" << std::endl;
332 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
333 std::cout << "Error in boostmultiset.erase(boostmultiset.begin())" << std::endl;
337 boostset.erase(boostset.begin());
338 stdset.erase(stdset.begin());
339 boostmultiset.erase(boostmultiset.begin());
340 stdmultiset.erase(stdmultiset.begin());
341 if(!CheckEqualContainers(boostset, stdset)){
342 std::cout << "Error in boostset.erase(boostset.begin())" << std::endl;
345 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
346 std::cout << "Error in boostmultiset.erase(boostmultiset.begin())" << std::endl;
352 MyBoostSet tmpboosteset2;
354 MyBoostMultiSet tmpboostemultiset2;
355 MyStdMultiSet tmpstdmultiset2;
356 boostset.swap(tmpboosteset2);
357 stdset.swap(tmpstdset2);
358 boostmultiset.swap(tmpboostemultiset2);
359 stdmultiset.swap(tmpstdmultiset2);
360 boostset.swap(tmpboosteset2);
361 stdset.swap(tmpstdset2);
362 boostmultiset.swap(tmpboostemultiset2);
363 stdmultiset.swap(tmpstdmultiset2);
364 if(!CheckEqualContainers(boostset, stdset)){
365 std::cout << "Error in boostset.swap(tmpboosteset2)" << std::endl;
368 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
369 std::cout << "Error in boostmultiset.swap(tmpboostemultiset2)" << std::endl;
374 //move constructor/assignment
376 MyBoostSet tmpboosteset2(boost::move(boostset));
377 if(!CheckEqualContainers(tmpboosteset2, stdset)){
378 std::cout << "Error in boostset move constructor " << std::endl;
381 MyBoostMultiSet tmpboostemultiset2(boost::move(boostmultiset));
382 if(!CheckEqualContainers(tmpboostemultiset2, stdmultiset)){
383 std::cout << "Error in boostmultiset move constructor " << std::endl;
387 boostset = boost::move(tmpboosteset2);
388 if(!CheckEqualContainers(boostset, stdset)){
389 std::cout << "Error in boostset move assignment" << std::endl;
392 boostmultiset = boost::move(tmpboostemultiset2);
393 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
394 std::cout << "Error in boostmultiset move assignment" << std::endl;
398 //Insertion from other container
401 IntType aux_vect[50];
402 for(int i = 0; i < 50; ++i){
404 aux_vect[i] = boost::move(move_me);
407 for(int i = 0; i < 50; ++i){
410 IntType aux_vect3[50];
411 for(int i = 0; i < 50; ++i){
413 aux_vect3[i] = boost::move(move_me);
416 boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
417 stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
418 if(!CheckEqualContainers(boostset, stdset)){
419 std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect3[0])..." << std::endl;
422 boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
423 stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
424 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
425 std::cout << "Error in boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), ..." << std::endl;
429 for(int i = 0, j = static_cast<int>(boostset.size()); i < j; ++i){
431 boostset.erase(erase_me);
433 boostmultiset.erase(erase_me);
434 stdmultiset.erase(i);
435 if(!CheckEqualContainers(boostset, stdset)){
436 std::cout << "Error in boostset.erase(erase_me)" << boostset.size() << " " << stdset.size() << std::endl;
439 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
440 std::cout << "Error in boostmultiset.erase(erase_me)" << std::endl;
446 IntType aux_vect[50];
447 for(int i = 0; i < 50; ++i){
449 aux_vect[i] = boost::move(move_me);
452 for(int i = 0; i < 50; ++i){
455 IntType aux_vect3[50];
456 for(int i = 0; i < 50; ++i){
458 aux_vect3[i] = boost::move(move_me);
461 IntType aux_vect4[50];
462 for(int i = 0; i < 50; ++i){
464 aux_vect4[i] = boost::move(move_me);
467 IntType aux_vect5[50];
468 for(int i = 0; i < 50; ++i){
470 aux_vect5[i] = boost::move(move_me);
473 boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
474 boostset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + 50));
475 stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
476 stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
477 if(!CheckEqualContainers(boostset, stdset)){
478 std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect3[0])..." << std::endl;
481 boostmultiset.insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(&aux_vect4[0] + 50));
482 boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(&aux_vect5[0] + 50));
483 stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
484 stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
485 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
486 std::cout << "Error in boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0])..." << std::endl;
490 boostset.erase(*boostset.begin());
491 stdset.erase(*stdset.begin());
492 if(!CheckEqualContainers(boostset, stdset)){
493 std::cout << "Error in boostset.erase(*boostset.begin())" << std::endl;
496 boostmultiset.erase(*boostmultiset.begin());
497 stdmultiset.erase(*stdmultiset.begin());
498 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
499 std::cout << "Error in boostmultiset.erase(*boostmultiset.begin())" << std::endl;
504 for(int i = 0; i < MaxElem; ++i){
506 boostset.insert(boost::move(move_me));
509 boostmultiset.insert(boost::move(move_me2));
510 stdmultiset.insert(i);
513 if(!CheckEqualContainers(boostset, stdset)){
514 std::cout << "Error in boostset.insert(boost::move(move_me)) try 2" << std::endl;
517 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
518 std::cout << "Error in boostmultiset.insert(boost::move(move_me2)) try 2" << std::endl;
522 for(int i = 0; i < MaxElem; ++i){
525 boostset.insert(boostset.begin(), boost::move(move_me));
526 stdset.insert(stdset.begin(), i);
527 //PrintContainers(boostset, stdset);
529 boostmultiset.insert(boostmultiset.begin(), boost::move(move_me2));
530 stdmultiset.insert(stdmultiset.begin(), i);
531 //PrintContainers(boostmultiset, stdmultiset);
532 if(!CheckEqualContainers(boostset, stdset)){
533 std::cout << "Error in boostset.insert(boostset.begin(), boost::move(move_me))" << std::endl;
536 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
537 std::cout << "Error in boostmultiset.insert(boostmultiset.begin(), boost::move(move_me2))" << std::endl;
542 boostset.insert(boostset.end(), boost::move(move_me3));
543 stdset.insert(stdset.end(), i);
545 boostmultiset.insert(boostmultiset.end(), boost::move(move_me4));
546 stdmultiset.insert(stdmultiset.end(), i);
547 if(!CheckEqualContainers(boostset, stdset)){
548 std::cout << "Error in boostset.insert(boostset.end(), boost::move(move_me3))" << std::endl;
551 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
552 std::cout << "Error in boostmultiset.insert(boostmultiset.end(), boost::move(move_me4))" << std::endl;
558 boostset.insert(boostset.upper_bound(move_me), boost::move(move_me));
559 stdset.insert(stdset.upper_bound(i), i);
560 //PrintContainers(boostset, stdset);
562 boostmultiset.insert(boostmultiset.upper_bound(move_me2), boost::move(move_me2));
563 stdmultiset.insert(stdmultiset.upper_bound(i), i);
564 //PrintContainers(boostmultiset, stdmultiset);
565 if(!CheckEqualContainers(boostset, stdset)){
566 std::cout << "Error in boostset.insert(boostset.upper_bound(move_me), boost::move(move_me))" << std::endl;
569 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
570 std::cout << "Error in boostmultiset.insert(boostmultiset.upper_bound(move_me2), boost::move(move_me2))" << std::endl;
578 boostset.insert(boostset.lower_bound(move_me), boost::move(move_me2));
579 stdset.insert(stdset.lower_bound(i), i);
580 //PrintContainers(boostset, stdset);
582 boostmultiset.insert(boostmultiset.lower_bound(move_me2), boost::move(move_me2));
583 stdmultiset.insert(stdmultiset.lower_bound(i), i);
584 //PrintContainers(boostmultiset, stdmultiset);
585 if(!CheckEqualContainers(boostset, stdset)){
586 std::cout << "Error in boostset.insert(boostset.lower_bound(move_me), boost::move(move_me2))" << std::endl;
589 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
590 std::cout << "Error in boostmultiset.insert(boostmultiset.lower_bound(move_me2), boost::move(move_me2))" << std::endl;
593 set_test_rebalanceable(boostset
594 , dtl::bool_<has_member_function_callable_with_rebalance<MyBoostSet>::value>());
595 if(!CheckEqualContainers(boostset, stdset)){
596 std::cout << "Error in boostset.rebalance()" << std::endl;
599 set_test_rebalanceable(boostmultiset
600 , dtl::bool_<has_member_function_callable_with_rebalance<MyBoostMultiSet>::value>());
601 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
602 std::cout << "Error in boostmultiset.rebalance()" << std::endl;
608 //Compare count with std containers
609 for(int i = 0; i < MaxElem; ++i){
611 if(boostset.count(k) != stdset.count(i)){
615 if(boostset.contains(k) != (stdset.find(i) != stdset.end())){
619 if(boostmultiset.count(k) != stdmultiset.count(i)){
623 if(boostmultiset.contains(k) != (stdmultiset.find(i) != stdmultiset.end())){
628 //Compare find/lower_bound/upper_bound in set
630 typename MyBoostSet::iterator bs_b = boostset.begin();
631 typename MyBoostSet::iterator bs_e = boostset.end();
632 typename MyStdSet::iterator ss_b = stdset.begin();
637 typename MyBoostSet::iterator bs_i;
638 typename MyStdSet::iterator ss_i;
640 bs_i = boostset.find(*bs_b);
641 ss_i = stdset.find(*ss_b);
642 if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
646 bs_i = boostset.lower_bound(*bs_b);
647 ss_i = stdset.lower_bound(*ss_b);
648 if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
652 bs_i = boostset.upper_bound(*bs_b);
653 ss_i = stdset.upper_bound(*ss_b);
654 if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
658 std::pair<typename MyBoostSet::iterator
659 ,typename MyBoostSet::iterator> bs_ip;
660 std::pair<typename MyStdSet::iterator
661 ,typename MyStdSet::iterator> ss_ip;
662 bs_ip = boostset.equal_range(*bs_b);
663 ss_ip = stdset.equal_range(*ss_b);
664 if(!CheckEqualIt(bs_ip.first, ss_ip.first, boostset, stdset)){
667 if(!CheckEqualIt(bs_ip.second, ss_ip.second, boostset, stdset)){
674 //Compare find/lower_bound/upper_bound in multiset
676 typename MyBoostMultiSet::iterator bm_b = boostmultiset.begin();
677 typename MyBoostMultiSet::iterator bm_e = boostmultiset.end();
678 typename MyStdMultiSet::iterator sm_b = stdmultiset.begin();
681 typename MyBoostMultiSet::iterator bm_i;
682 typename MyStdMultiSet::iterator sm_i;
684 bm_i = boostmultiset.find(*bm_b);
685 sm_i = stdmultiset.find(*sm_b);
686 if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
690 bm_i = boostmultiset.lower_bound(*bm_b);
691 sm_i = stdmultiset.lower_bound(*sm_b);
692 if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
696 bm_i = boostmultiset.upper_bound(*bm_b);
697 sm_i = stdmultiset.upper_bound(*sm_b);
698 if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
702 std::pair<typename MyBoostMultiSet::iterator
703 ,typename MyBoostMultiSet::iterator> bm_ip;
704 std::pair<typename MyStdMultiSet::iterator
705 ,typename MyStdMultiSet::iterator> sm_ip;
706 bm_ip = boostmultiset.equal_range(*bm_b);
707 sm_ip = stdmultiset.equal_range(*sm_b);
708 if(!CheckEqualIt(bm_ip.first, sm_ip.first, boostmultiset, stdmultiset)){
711 if(!CheckEqualIt(bm_ip.second, sm_ip.second, boostmultiset, stdmultiset)){
719 //Now do count exercise
720 boostset.erase(boostset.begin(), boostset.end());
721 boostmultiset.erase(boostmultiset.begin(), boostmultiset.end());
723 boostmultiset.clear();
725 for(int j = 0; j < 3; ++j)
726 for(int i = 0; i < 100; ++i){
728 boostset.insert(boost::move(move_me));
730 boostmultiset.insert(boost::move(move_me2));
732 if(boostset.count(count_me) != typename MyBoostMultiSet::size_type(1)){
733 std::cout << "Error in boostset.count(count_me)" << std::endl;
736 if(boostmultiset.count(count_me) != typename MyBoostMultiSet::size_type(j+1)){
737 std::cout << "Error in boostmultiset.count(count_me)" << std::endl;
743 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>();
744 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>();
746 MyBoostSet &boostset2 = *pboostset2;
747 MyBoostMultiSet &boostmultiset2 = *pboostmultiset2;
751 boostmultiset.clear();
752 boostmultiset2.clear();
757 IntType aux_vect[MaxElem];
758 for(int i = 0; i < MaxElem; ++i){
762 IntType aux_vect2[MaxElem];
763 for(int i = 0; i < MaxElem; ++i){
764 aux_vect2[i] = MaxElem/2+i;
766 IntType aux_vect3[MaxElem];
767 for(int i = 0; i < MaxElem; ++i){
768 aux_vect3[i] = MaxElem*2/2+i;
770 boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + MaxElem));
771 boostset2.insert(boost::make_move_iterator(&aux_vect2[0]), boost::make_move_iterator(&aux_vect2[0] + MaxElem));
772 boostmultiset2.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + MaxElem));
774 for(int i = 0; i < MaxElem; ++i){
777 for(int i = 0; i < MaxElem; ++i){
778 stdset.insert(MaxElem/2+i);
781 boostset.merge(boost::move(boostset2));
782 if(!CheckEqualContainers(boostset, stdset)) return 1;
784 for(int i = 0; i < MaxElem; ++i){
785 stdset.insert(MaxElem*2/2+i);
788 boostset.merge(boost::move(boostmultiset2));
789 if(!CheckEqualContainers(boostset, stdset)) return 1;
793 boostmultiset.clear();
794 boostmultiset2.clear();
798 IntType aux_vect[MaxElem];
799 for(int i = 0; i < MaxElem; ++i){
803 IntType aux_vect2[MaxElem];
804 for(int i = 0; i < MaxElem; ++i){
805 aux_vect2[i] = MaxElem/2+i;
807 IntType aux_vect3[MaxElem];
808 for(int i = 0; i < MaxElem; ++i){
809 aux_vect3[i] = MaxElem*2/2+i;
811 boostmultiset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + MaxElem));
812 boostmultiset2.insert(boost::make_move_iterator(&aux_vect2[0]), boost::make_move_iterator(&aux_vect2[0] + MaxElem));
813 boostset2.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + MaxElem));
815 for(int i = 0; i < MaxElem; ++i){
816 stdmultiset.insert(i);
818 for(int i = 0; i < MaxElem; ++i){
819 stdmultiset.insert(MaxElem/2+i);
821 boostmultiset.merge(boost::move(boostmultiset2));
822 if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
824 for(int i = 0; i < MaxElem; ++i){
825 stdmultiset.insert(MaxElem*2/2+i);
828 boostmultiset.merge(boost::move(boostset2));
829 if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
832 if(set_test_copyable<MyBoostSet, MyStdSet, MyBoostMultiSet, MyStdMultiSet>
833 (dtl::bool_<boost::container::test::is_copyable<IntType>::value>())){
840 template<typename SetType>
841 bool test_set_methods_with_initializer_list_as_argument_for()
843 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
844 std::initializer_list<int> il = { 1, 2, 3, 4, 5, 5 };
845 std::initializer_list<int> ilu = { 1, 2, 3, 4, 5 };
846 SetType expected(il.begin(), il.end());
847 SetType expectedu(ilu.begin(), ilu.end());
853 SetType sila(il, typename SetType::allocator_type());
854 if (sila != expected)
857 SetType silca(il, typename SetType::key_compare(), typename SetType::allocator_type());
858 if (silca != expected)
861 SetType sil_ordered(ordered_unique_range, ilu);
862 if (sil_ordered != expectedu)
865 SetType sil_assign = { 99, 100, 101, 102, 103, 104, 105 };
867 if (sil_assign != expected)
881 template<typename SetType, typename MultisetType>
882 bool instantiate_constructors()
885 typedef typename SetType::value_type value_type;
886 typename SetType::key_compare comp;
887 typename SetType::allocator_type a;
896 SetType s0(&value, &value);
897 SetType s1(&value, &value ,comp);
898 SetType s2(&value, &value ,a);
899 SetType s3(&value, &value ,comp, a);
901 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
904 SetType s1({ 0 },comp);
906 SetType s3({ 0 },comp, a);
909 std::initializer_list<value_type> il{0};
910 SetType s0(ordered_unique_range, il);
911 SetType s1(ordered_unique_range, il,comp);
912 SetType s3(ordered_unique_range, il,comp, a);
916 SetType s0(ordered_unique_range, &value, &value);
917 SetType s1(ordered_unique_range, &value, &value ,comp);
918 SetType s2(ordered_unique_range, &value, &value ,comp, a);
923 typedef typename MultisetType::value_type value_type;
924 typename MultisetType::key_compare comp;
925 typename MultisetType::allocator_type a;
929 MultisetType s1(comp);
931 MultisetType s3(comp, a);
934 MultisetType s0(&value, &value);
935 MultisetType s1(&value, &value ,comp);
936 MultisetType s2(&value, &value ,a);
937 MultisetType s3(&value, &value ,comp, a);
939 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
941 MultisetType s0({ 0 });
942 MultisetType s1({ 0 },comp);
943 MultisetType s2({ 0 },a);
944 MultisetType s3({ 0 },comp, a);
947 std::initializer_list<value_type>il{0};
948 MultisetType s0(ordered_range, il);
949 MultisetType s1(ordered_range, il,comp);
950 MultisetType s3(ordered_range, il,comp, a);
954 MultisetType s0(ordered_range, &value, &value);
955 MultisetType s1(ordered_range, &value, &value ,comp);
956 MultisetType s2(ordered_range, &value, &value ,comp, a);
963 } //namespace container {
966 #include <boost/container/detail/config_end.hpp>