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 <boost/move/utility_core.hpp>
18 #include <boost/move/iterator.hpp>
19 #include <boost/move/make_unique.hpp>
21 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_FUNCNAME rebalance
22 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_BEG namespace boost { namespace container { namespace test {
23 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_NS_END }}}
24 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MIN 0
25 #define BOOST_INTRUSIVE_HAS_MEMBER_FUNCTION_CALLABLE_WITH_MAX 0
26 #include <boost/intrusive/detail/has_member_function_callable_with.hpp>
33 void set_test_rebalanceable(C &, boost::container::container_detail::false_type)
37 void set_test_rebalanceable(C &c, boost::container::container_detail::true_type)
42 template<class MyBoostSet
44 ,class MyBoostMultiSet
46 int set_test_copyable(boost::container::container_detail::false_type)
49 const int MaxElem = 50;
51 template<class MyBoostSet
53 ,class MyBoostMultiSet
55 int set_test_copyable(boost::container::container_detail::true_type)
57 typedef typename MyBoostSet::value_type IntType;
59 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset = ::boost::movelib::make_unique<MyBoostSet>();
60 ::boost::movelib::unique_ptr<MyStdSet> const pstdset = ::boost::movelib::make_unique<MyStdSet>();
61 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset = ::boost::movelib::make_unique<MyBoostMultiSet>();
62 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset = ::boost::movelib::make_unique<MyStdMultiSet>();
64 MyBoostSet &boostset = *pboostset;
65 MyStdSet &stdset = *pstdset;
66 MyBoostMultiSet &boostmultiset = *pboostmultiset;
67 MyStdMultiSet &stdmultiset = *pstdmultiset;
69 //Just to test move aware catch conversions
70 boostset.insert(boostset.cbegin(), boostset.cend());
71 boostmultiset.insert(boostmultiset.cbegin(), boostmultiset.cend());
72 boostset.insert(boostset.begin(), boostset.end());
73 boostmultiset.insert(boostmultiset.begin(), boostmultiset.end());
75 for(int i = 0; i < MaxElem; ++i){
77 boostset.insert(boost::move(move_me));
80 boostmultiset.insert(boost::move(move_me2));
81 stdmultiset.insert(i);
83 if(!CheckEqualContainers(boostset, stdset)) return 1;
84 if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
87 //Now, test copy constructor
88 MyBoostSet boostsetcopy(boostset);
89 MyStdSet stdsetcopy(stdset);
91 if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
94 MyBoostMultiSet boostmsetcopy(boostmultiset);
95 MyStdMultiSet stdmsetcopy(stdmultiset);
97 if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
101 boostsetcopy =boostset;
104 if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
107 boostmsetcopy = boostmultiset;
108 stdmsetcopy = stdmultiset;
110 if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
114 //Now, test copy constructor
115 MyBoostSet boostsetcopy(boostset, typename MyBoostSet::allocator_type());
116 MyStdSet stdsetcopy(stdset);
118 if(!CheckEqualContainers(boostsetcopy, stdsetcopy))
121 MyBoostMultiSet boostmsetcopy(boostmultiset, typename MyBoostSet::allocator_type());
122 MyStdMultiSet stdmsetcopy(stdmultiset);
124 if(!CheckEqualContainers(boostmsetcopy, stdmsetcopy))
131 template<class MyBoostSet
133 ,class MyBoostMultiSet
134 ,class MyStdMultiSet>
137 typedef typename MyBoostSet::value_type IntType;
139 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset = ::boost::movelib::make_unique<MyBoostSet>();
140 ::boost::movelib::unique_ptr<MyStdSet> const pstdset = ::boost::movelib::make_unique<MyStdSet>();
141 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset = ::boost::movelib::make_unique<MyBoostMultiSet>();
142 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset = ::boost::movelib::make_unique<MyStdMultiSet>();
144 MyBoostSet &boostset = *pboostset;
145 MyStdSet &stdset = *pstdset;
146 MyBoostMultiSet &boostmultiset = *pboostmultiset;
147 MyStdMultiSet &stdmultiset = *pstdmultiset;
149 //Test construction from a range
150 { //Set(beg, end, compare)
151 IntType aux_vect[50];
152 for(int i = 0; i < 50; ++i){
153 IntType move_me(i/2);
154 aux_vect[i] = boost::move(move_me);
157 for(int i = 0; i < 50; ++i){
160 IntType aux_vect3[50];
161 for(int i = 0; i < 50; ++i){
162 IntType move_me(i/2);
163 aux_vect3[i] = boost::move(move_me);
165 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
166 (boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0]+50), typename MyBoostSet::key_compare());
167 ::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>(&aux_vect2[0], &aux_vect2[0]+50);
168 if(!test::CheckEqualContainers(*pboostset2, *pstdset2)) return 1;
169 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>
170 (boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0]+50), typename MyBoostMultiSet::key_compare());
171 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset2 = ::boost::movelib::make_unique<MyStdMultiSet>(&aux_vect2[0], &aux_vect2[0]+50);
172 if(!test::CheckEqualContainers(*pboostmultiset2, *pstdmultiset2)) return 1;
174 { //Set(beg, end, alloc)
175 IntType aux_vect[50];
176 for(int i = 0; i < 50; ++i){
177 IntType move_me(i/2);
178 aux_vect[i] = boost::move(move_me);
181 for(int i = 0; i < 50; ++i){
184 IntType aux_vect3[50];
185 for(int i = 0; i < 50; ++i){
186 IntType move_me(i/2);
187 aux_vect3[i] = boost::move(move_me);
189 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
190 (boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0]+50), typename MyBoostSet::allocator_type());
191 ::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>(&aux_vect2[0], &aux_vect2[0]+50);
192 if(!test::CheckEqualContainers(*pboostset2, *pstdset2)) return 1;
193 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>
194 (boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0]+50), typename MyBoostMultiSet::allocator_type());
195 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset2 = ::boost::movelib::make_unique<MyStdMultiSet>(&aux_vect2[0], &aux_vect2[0]+50);
196 if(!test::CheckEqualContainers(*pboostmultiset2, *pstdmultiset2)) return 1;
199 IntType aux_vect[50];
200 for(int i = 0; i < 50; ++i){
201 IntType move_me(i/2);
202 aux_vect[i] = boost::move(move_me);
205 for(int i = 0; i < 50; ++i){
208 IntType aux_vect3[50];
209 for(int i = 0; i < 50; ++i){
210 IntType move_me(i/2);
211 aux_vect3[i] = boost::move(move_me);
214 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>
215 ( boost::make_move_iterator(&aux_vect[0])
216 , boost::make_move_iterator(aux_vect + 50));
217 ::boost::movelib::unique_ptr<MyStdSet> const pstdset2 = ::boost::movelib::make_unique<MyStdSet>
218 (&aux_vect2[0], &aux_vect2[0] + 50);
219 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>
220 ( boost::make_move_iterator(&aux_vect3[0])
221 , boost::make_move_iterator(aux_vect3 + 50));
222 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset2 = ::boost::movelib::make_unique<MyStdMultiSet>
223 (&aux_vect2[0], &aux_vect2[0] + 50);
225 MyBoostSet &boostset2 = *pboostset2;
226 MyStdSet &stdset2 = *pstdset2;
227 MyBoostMultiSet &boostmultiset2 = *pboostmultiset2;
228 MyStdMultiSet &stdmultiset2 = *pstdmultiset2;
230 if(!CheckEqualContainers(boostset2, stdset2)){
231 std::cout << "Error in construct<MyBoostSet>(MyBoostSet2)" << std::endl;
234 if(!CheckEqualContainers(boostmultiset2, stdmultiset2)){
235 std::cout << "Error in construct<MyBoostMultiSet>(MyBoostMultiSet2)" << std::endl;
239 //ordered range insertion
240 for(int i = 0; i < 50; ++i){
242 aux_vect[i] = boost::move(move_me);
245 for(int i = 0; i < 50; ++i){
249 for(int i = 0; i < 50; ++i){
251 aux_vect3[i] = boost::move(move_me);
254 //some comparison operators
255 if(!(boostset2 == boostset2))
257 if(boostset2 != boostset2)
259 if(boostset2 < boostset2)
261 if(boostset2 > boostset2)
263 if(!(boostset2 <= boostset2))
265 if(!(boostset2 >= boostset2))
268 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset3 = ::boost::movelib::make_unique<MyBoostSet>
269 ( ordered_unique_range
270 , boost::make_move_iterator(&aux_vect[0])
271 , boost::make_move_iterator(&aux_vect[0] + 50));
272 ::boost::movelib::unique_ptr<MyStdSet> const pstdset3 = ::boost::movelib::make_unique<MyStdSet>
273 (&aux_vect2[0], &aux_vect2[0] + 50);
274 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset3 = ::boost::movelib::make_unique<MyBoostMultiSet>
276 , boost::make_move_iterator(&aux_vect3[0])
277 , boost::make_move_iterator(aux_vect3 + 50));
278 ::boost::movelib::unique_ptr<MyStdMultiSet> const pstdmultiset3 = ::boost::movelib::make_unique<MyStdMultiSet>
279 (&aux_vect2[0], &aux_vect2[0] + 50);
281 MyBoostSet &boostset3 = *pboostset3;
282 MyStdSet &stdset3 = *pstdset3;
283 MyBoostMultiSet &boostmultiset3 = *pboostmultiset3;
284 MyStdMultiSet &stdmultiset3 = *pstdmultiset3;
286 if(!CheckEqualContainers(boostset3, stdset3)){
287 std::cout << "Error in construct<MyBoostSet>(MyBoostSet3)" << std::endl;
290 if(!CheckEqualContainers(boostmultiset3, stdmultiset3)){
291 std::cout << "Error in construct<MyBoostMultiSet>(MyBoostMultiSet3)" << std::endl;
296 for(int i = 0; i < MaxElem; ++i){
298 boostset.insert(boost::move(move_me));
300 boostset.insert(IntType(i));
303 boostmultiset.insert(boost::move(move_me2));
304 stdmultiset.insert(i);
305 boostmultiset.insert(IntType(i));
306 stdmultiset.insert(i);
309 if(!CheckEqualContainers(boostset, stdset)){
310 std::cout << "Error in boostset.insert(boost::move(move_me)" << std::endl;
314 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
315 std::cout << "Error in boostmultiset.insert(boost::move(move_me)" << std::endl;
319 typename MyBoostSet::iterator it = boostset.begin();
320 typename MyBoostSet::const_iterator cit = it;
323 boostset.erase(boostset.begin());
324 stdset.erase(stdset.begin());
325 boostmultiset.erase(boostmultiset.begin());
326 stdmultiset.erase(stdmultiset.begin());
327 if(!CheckEqualContainers(boostset, stdset)){
328 std::cout << "Error in boostset.erase(boostset.begin())" << std::endl;
331 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
332 std::cout << "Error in boostmultiset.erase(boostmultiset.begin())" << std::endl;
336 boostset.erase(boostset.begin());
337 stdset.erase(stdset.begin());
338 boostmultiset.erase(boostmultiset.begin());
339 stdmultiset.erase(stdmultiset.begin());
340 if(!CheckEqualContainers(boostset, stdset)){
341 std::cout << "Error in boostset.erase(boostset.begin())" << std::endl;
344 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
345 std::cout << "Error in boostmultiset.erase(boostmultiset.begin())" << std::endl;
350 MyBoostSet tmpboosteset2;
352 MyBoostMultiSet tmpboostemultiset2;
353 MyStdMultiSet tmpstdmultiset2;
354 boostset.swap(tmpboosteset2);
355 stdset.swap(tmpstdset2);
356 boostmultiset.swap(tmpboostemultiset2);
357 stdmultiset.swap(tmpstdmultiset2);
358 boostset.swap(tmpboosteset2);
359 stdset.swap(tmpstdset2);
360 boostmultiset.swap(tmpboostemultiset2);
361 stdmultiset.swap(tmpstdmultiset2);
362 if(!CheckEqualContainers(boostset, stdset)){
363 std::cout << "Error in boostset.swap(tmpboosteset2)" << std::endl;
366 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
367 std::cout << "Error in boostmultiset.swap(tmpboostemultiset2)" << std::endl;
371 //Insertion from other container
374 IntType aux_vect[50];
375 for(int i = 0; i < 50; ++i){
377 aux_vect[i] = boost::move(move_me);
380 for(int i = 0; i < 50; ++i){
383 IntType aux_vect3[50];
384 for(int i = 0; i < 50; ++i){
386 aux_vect3[i] = boost::move(move_me);
389 boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
390 stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
391 boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(aux_vect3 + 50));
392 stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
393 if(!CheckEqualContainers(boostset, stdset)){
394 std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect[0])..." << std::endl;
397 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
398 std::cout << "Error in boostmultiset.insert(boost::make_move_iterator(&aux_vect3[0]), ..." << std::endl;
402 for(int i = 0, j = static_cast<int>(boostset.size()); i < j; ++i){
404 boostset.erase(erase_me);
406 boostmultiset.erase(erase_me);
407 stdmultiset.erase(i);
408 if(!CheckEqualContainers(boostset, stdset)){
409 std::cout << "Error in boostset.erase(erase_me)" << boostset.size() << " " << stdset.size() << std::endl;
412 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
413 std::cout << "Error in boostmultiset.erase(erase_me)" << std::endl;
419 IntType aux_vect[50];
420 for(int i = 0; i < 50; ++i){
422 aux_vect[i] = boost::move(move_me);
425 for(int i = 0; i < 50; ++i){
428 IntType aux_vect3[50];
429 for(int i = 0; i < 50; ++i){
431 aux_vect3[i] = boost::move(move_me);
434 IntType aux_vect4[50];
435 for(int i = 0; i < 50; ++i){
437 aux_vect4[i] = boost::move(move_me);
440 IntType aux_vect5[50];
441 for(int i = 0; i < 50; ++i){
443 aux_vect5[i] = boost::move(move_me);
446 boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + 50));
447 boostset.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + 50));
448 stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
449 stdset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
450 boostmultiset.insert(boost::make_move_iterator(&aux_vect4[0]), boost::make_move_iterator(&aux_vect4[0] + 50));
451 boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0]), boost::make_move_iterator(&aux_vect5[0] + 50));
452 stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
453 stdmultiset.insert(&aux_vect2[0], &aux_vect2[0] + 50);
454 if(!CheckEqualContainers(boostset, stdset)){
455 std::cout << "Error in boostset.insert(boost::make_move_iterator(&aux_vect3[0])..." << std::endl;
458 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
459 std::cout << "Error in boostmultiset.insert(boost::make_move_iterator(&aux_vect5[0])..." << std::endl;
463 boostset.erase(*boostset.begin());
464 stdset.erase(*stdset.begin());
465 boostmultiset.erase(*boostmultiset.begin());
466 stdmultiset.erase(*stdmultiset.begin());
467 if(!CheckEqualContainers(boostset, stdset)){
468 std::cout << "Error in boostset.erase(*boostset.begin())" << std::endl;
471 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
472 std::cout << "Error in boostmultiset.erase(*boostmultiset.begin())" << std::endl;
477 for(int i = 0; i < MaxElem; ++i){
479 boostset.insert(boost::move(move_me));
482 boostmultiset.insert(boost::move(move_me2));
483 stdmultiset.insert(i);
486 if(!CheckEqualContainers(boostset, stdset)){
487 std::cout << "Error in boostset.insert(boost::move(move_me)) try 2" << std::endl;
490 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
491 std::cout << "Error in boostmultiset.insert(boost::move(move_me2)) try 2" << std::endl;
495 for(int i = 0; i < MaxElem; ++i){
498 boostset.insert(boostset.begin(), boost::move(move_me));
499 stdset.insert(stdset.begin(), i);
500 //PrintContainers(boostset, stdset);
502 boostmultiset.insert(boostmultiset.begin(), boost::move(move_me2));
503 stdmultiset.insert(stdmultiset.begin(), i);
504 //PrintContainers(boostmultiset, stdmultiset);
505 if(!CheckEqualContainers(boostset, stdset)){
506 std::cout << "Error in boostset.insert(boostset.begin(), boost::move(move_me))" << std::endl;
509 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
510 std::cout << "Error in boostmultiset.insert(boostmultiset.begin(), boost::move(move_me2))" << std::endl;
515 boostset.insert(boostset.end(), boost::move(move_me3));
516 stdset.insert(stdset.end(), i);
518 boostmultiset.insert(boostmultiset.end(), boost::move(move_me4));
519 stdmultiset.insert(stdmultiset.end(), i);
520 if(!CheckEqualContainers(boostset, stdset)){
521 std::cout << "Error in boostset.insert(boostset.end(), boost::move(move_me3))" << std::endl;
524 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
525 std::cout << "Error in boostmultiset.insert(boostmultiset.end(), boost::move(move_me4))" << std::endl;
531 boostset.insert(boostset.upper_bound(move_me), boost::move(move_me));
532 stdset.insert(stdset.upper_bound(i), i);
533 //PrintContainers(boostset, stdset);
535 boostmultiset.insert(boostmultiset.upper_bound(move_me2), boost::move(move_me2));
536 stdmultiset.insert(stdmultiset.upper_bound(i), i);
537 //PrintContainers(boostmultiset, stdmultiset);
538 if(!CheckEqualContainers(boostset, stdset)){
539 std::cout << "Error in boostset.insert(boostset.upper_bound(move_me), boost::move(move_me))" << std::endl;
542 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
543 std::cout << "Error in boostmultiset.insert(boostmultiset.upper_bound(move_me2), boost::move(move_me2))" << std::endl;
551 boostset.insert(boostset.lower_bound(move_me), boost::move(move_me2));
552 stdset.insert(stdset.lower_bound(i), i);
553 //PrintContainers(boostset, stdset);
555 boostmultiset.insert(boostmultiset.lower_bound(move_me2), boost::move(move_me2));
556 stdmultiset.insert(stdmultiset.lower_bound(i), i);
557 //PrintContainers(boostmultiset, stdmultiset);
558 if(!CheckEqualContainers(boostset, stdset)){
559 std::cout << "Error in boostset.insert(boostset.lower_bound(move_me), boost::move(move_me2))" << std::endl;
562 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
563 std::cout << "Error in boostmultiset.insert(boostmultiset.lower_bound(move_me2), boost::move(move_me2))" << std::endl;
566 set_test_rebalanceable(boostset
567 , container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostSet>::value>());
568 if(!CheckEqualContainers(boostset, stdset)){
569 std::cout << "Error in boostset.rebalance()" << std::endl;
572 set_test_rebalanceable(boostmultiset
573 , container_detail::bool_<has_member_function_callable_with_rebalance<MyBoostMultiSet>::value>());
574 if(!CheckEqualContainers(boostmultiset, stdmultiset)){
575 std::cout << "Error in boostmultiset.rebalance()" << std::endl;
581 //Compare count with std containers
582 for(int i = 0; i < MaxElem; ++i){
584 if(boostset.count(count_me) != stdset.count(i)){
587 if(boostmultiset.count(count_me) != stdmultiset.count(i)){
592 //Compare find/lower_bound/upper_bound in set
594 typename MyBoostSet::iterator bs_b = boostset.begin();
595 typename MyBoostSet::iterator bs_e = boostset.end();
596 typename MyStdSet::iterator ss_b = stdset.begin();
601 typename MyBoostSet::iterator bs_i;
602 typename MyStdSet::iterator ss_i;
604 bs_i = boostset.find(*bs_b);
605 ss_i = stdset.find(*ss_b);
606 if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
610 bs_i = boostset.lower_bound(*bs_b);
611 ss_i = stdset.lower_bound(*ss_b);
612 if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
616 bs_i = boostset.upper_bound(*bs_b);
617 ss_i = stdset.upper_bound(*ss_b);
618 if(!CheckEqualIt(bs_i, ss_i, boostset, stdset)){
622 std::pair<typename MyBoostSet::iterator
623 ,typename MyBoostSet::iterator> bs_ip;
624 std::pair<typename MyStdSet::iterator
625 ,typename MyStdSet::iterator> ss_ip;
626 bs_ip = boostset.equal_range(*bs_b);
627 ss_ip = stdset.equal_range(*ss_b);
628 if(!CheckEqualIt(bs_ip.first, ss_ip.first, boostset, stdset)){
631 if(!CheckEqualIt(bs_ip.second, ss_ip.second, boostset, stdset)){
638 //Compare find/lower_bound/upper_bound in multiset
640 typename MyBoostMultiSet::iterator bm_b = boostmultiset.begin();
641 typename MyBoostMultiSet::iterator bm_e = boostmultiset.end();
642 typename MyStdMultiSet::iterator sm_b = stdmultiset.begin();
645 typename MyBoostMultiSet::iterator bm_i;
646 typename MyStdMultiSet::iterator sm_i;
648 bm_i = boostmultiset.find(*bm_b);
649 sm_i = stdmultiset.find(*sm_b);
650 if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
654 bm_i = boostmultiset.lower_bound(*bm_b);
655 sm_i = stdmultiset.lower_bound(*sm_b);
656 if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
660 bm_i = boostmultiset.upper_bound(*bm_b);
661 sm_i = stdmultiset.upper_bound(*sm_b);
662 if(!CheckEqualIt(bm_i, sm_i, boostmultiset, stdmultiset)){
666 std::pair<typename MyBoostMultiSet::iterator
667 ,typename MyBoostMultiSet::iterator> bm_ip;
668 std::pair<typename MyStdMultiSet::iterator
669 ,typename MyStdMultiSet::iterator> sm_ip;
670 bm_ip = boostmultiset.equal_range(*bm_b);
671 sm_ip = stdmultiset.equal_range(*sm_b);
672 if(!CheckEqualIt(bm_ip.first, sm_ip.first, boostmultiset, stdmultiset)){
675 if(!CheckEqualIt(bm_ip.second, sm_ip.second, boostmultiset, stdmultiset)){
683 //Now do count exercise
684 boostset.erase(boostset.begin(), boostset.end());
685 boostmultiset.erase(boostmultiset.begin(), boostmultiset.end());
687 boostmultiset.clear();
689 for(int j = 0; j < 3; ++j)
690 for(int i = 0; i < 100; ++i){
692 boostset.insert(boost::move(move_me));
694 boostmultiset.insert(boost::move(move_me2));
696 if(boostset.count(count_me) != typename MyBoostMultiSet::size_type(1)){
697 std::cout << "Error in boostset.count(count_me)" << std::endl;
700 if(boostmultiset.count(count_me) != typename MyBoostMultiSet::size_type(j+1)){
701 std::cout << "Error in boostmultiset.count(count_me)" << std::endl;
707 ::boost::movelib::unique_ptr<MyBoostSet> const pboostset2 = ::boost::movelib::make_unique<MyBoostSet>();
708 ::boost::movelib::unique_ptr<MyBoostMultiSet> const pboostmultiset2 = ::boost::movelib::make_unique<MyBoostMultiSet>();
710 MyBoostSet &boostset2 = *pboostset2;
711 MyBoostMultiSet &boostmultiset2 = *pboostmultiset2;
715 boostmultiset.clear();
716 boostmultiset2.clear();
721 IntType aux_vect[MaxElem];
722 for(int i = 0; i < MaxElem; ++i){
726 IntType aux_vect2[MaxElem];
727 for(int i = 0; i < MaxElem; ++i){
728 aux_vect2[i] = MaxElem/2+i;
730 IntType aux_vect3[MaxElem];
731 for(int i = 0; i < MaxElem; ++i){
732 aux_vect3[i] = MaxElem*2/2+i;
734 boostset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + MaxElem));
735 boostset2.insert(boost::make_move_iterator(&aux_vect2[0]), boost::make_move_iterator(&aux_vect2[0] + MaxElem));
736 boostmultiset2.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + MaxElem));
738 for(int i = 0; i < MaxElem; ++i){
741 for(int i = 0; i < MaxElem; ++i){
742 stdset.insert(MaxElem/2+i);
745 boostset.merge(boost::move(boostset2));
746 if(!CheckEqualContainers(boostset, stdset)) return 1;
748 for(int i = 0; i < MaxElem; ++i){
749 stdset.insert(MaxElem*2/2+i);
752 boostset.merge(boost::move(boostmultiset2));
753 if(!CheckEqualContainers(boostset, stdset)) return 1;
757 boostmultiset.clear();
758 boostmultiset2.clear();
762 IntType aux_vect[MaxElem];
763 for(int i = 0; i < MaxElem; ++i){
767 IntType aux_vect2[MaxElem];
768 for(int i = 0; i < MaxElem; ++i){
769 aux_vect2[i] = MaxElem/2+i;
771 IntType aux_vect3[MaxElem];
772 for(int i = 0; i < MaxElem; ++i){
773 aux_vect3[i] = MaxElem*2/2+i;
775 boostmultiset.insert(boost::make_move_iterator(&aux_vect[0]), boost::make_move_iterator(&aux_vect[0] + MaxElem));
776 boostmultiset2.insert(boost::make_move_iterator(&aux_vect2[0]), boost::make_move_iterator(&aux_vect2[0] + MaxElem));
777 boostset2.insert(boost::make_move_iterator(&aux_vect3[0]), boost::make_move_iterator(&aux_vect3[0] + MaxElem));
779 for(int i = 0; i < MaxElem; ++i){
780 stdmultiset.insert(i);
782 for(int i = 0; i < MaxElem; ++i){
783 stdmultiset.insert(MaxElem/2+i);
785 boostmultiset.merge(boost::move(boostmultiset2));
786 if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
788 for(int i = 0; i < MaxElem; ++i){
789 stdmultiset.insert(MaxElem*2/2+i);
792 boostmultiset.merge(boost::move(boostset2));
793 if(!CheckEqualContainers(boostmultiset, stdmultiset)) return 1;
796 if(set_test_copyable<MyBoostSet, MyStdSet, MyBoostMultiSet, MyStdMultiSet>
797 (container_detail::bool_<boost::container::test::is_copyable<IntType>::value>())){
804 template<typename SetType>
805 bool test_set_methods_with_initializer_list_as_argument_for()
807 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
808 std::initializer_list<int> il = { 1, 2, 3, 4, 5, 5 };
809 std::initializer_list<int> ilu = { 1, 2, 3, 4, 5 };
810 SetType expected(il.begin(), il.end());
811 SetType expectedu(ilu.begin(), ilu.end());
817 SetType sila(il, typename SetType::allocator_type());
818 if (sila != expected)
821 SetType silca(il, typename SetType::key_compare(), typename SetType::allocator_type());
822 if (silca != expected)
825 SetType sil_ordered(ordered_unique_range, ilu);
826 if (sil_ordered != expectedu)
829 SetType sil_assign = { 99, 100, 101, 102, 103, 104, 105 };
831 if (sil_assign != expected)
845 template<typename SetType, typename MultisetType>
846 bool instantiate_constructors()
849 typedef typename SetType::value_type value_type;
850 typename SetType::key_compare comp;
851 typename SetType::allocator_type a;
860 SetType s0(&value, &value);
861 SetType s1(&value, &value ,comp);
862 SetType s2(&value, &value ,a);
863 SetType s3(&value, &value ,comp, a);
865 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
868 SetType s1({ 0 },comp);
870 SetType s3({ 0 },comp, a);
873 std::initializer_list<value_type> il{0};
874 SetType s0(ordered_unique_range, il);
875 SetType s1(ordered_unique_range, il,comp);
876 SetType s3(ordered_unique_range, il,comp, a);
880 SetType s0(ordered_unique_range, &value, &value);
881 SetType s1(ordered_unique_range, &value, &value ,comp);
882 SetType s2(ordered_unique_range, &value, &value ,comp, a);
887 typedef typename MultisetType::value_type value_type;
888 typename MultisetType::key_compare comp;
889 typename MultisetType::allocator_type a;
893 MultisetType s1(comp);
895 MultisetType s3(comp, a);
898 MultisetType s0(&value, &value);
899 MultisetType s1(&value, &value ,comp);
900 MultisetType s2(&value, &value ,a);
901 MultisetType s3(&value, &value ,comp, a);
903 #if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
905 MultisetType s0({ 0 });
906 MultisetType s1({ 0 },comp);
907 MultisetType s2({ 0 },a);
908 MultisetType s3({ 0 },comp, a);
911 std::initializer_list<value_type>il{0};
912 MultisetType s0(ordered_range, il);
913 MultisetType s1(ordered_range, il,comp);
914 MultisetType s3(ordered_range, il,comp, a);
918 MultisetType s0(ordered_range, &value, &value);
919 MultisetType s1(ordered_range, &value, &value ,comp);
920 MultisetType s2(ordered_range, &value, &value ,comp, a);
927 } //namespace container {
930 #include <boost/container/detail/config_end.hpp>