From 6d4af66addfdb4b4262f5acea09187d6d33f0db6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ion=20Gazta=C3=B1aga?= Date: Sat, 24 Nov 2012 21:09:10 +0000 Subject: [PATCH] * Improved `vector`'s insertion performance. * Changed again experimental multiallocation interface for better performance (still experimental). * Added no exception support for those willing to disable exceptions in their compilers. * Fixed GCC -Wshadow warnings. * Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros. [SVN r81519] --- doc/container.qbk | 10 + example/doc_move_containers.cpp | 2 +- proj/to-do.txt | 99 +--------- proj/vc7ide/container.vcproj | 3 + test/allocator_traits_test.cpp | 2 +- test/deque_test.cpp | 12 +- test/dummy_test_allocator.hpp | 12 +- test/emplace_test.hpp | 257 +++++++++++++++++-------- test/expand_bwd_test_allocator.hpp | 7 +- test/flat_tree_test.cpp | 74 +++++++ test/list_test.hpp | 3 +- test/map_test.hpp | 25 +-- test/movable_int.hpp | 3 +- test/scoped_allocator_adaptor_test.cpp | 2 +- test/scoped_allocator_usage_test.cpp | 2 +- test/set_test.hpp | 82 ++++---- test/string_test.cpp | 3 - test/vector_test.cpp | 9 +- test/vector_test.hpp | 4 +- 19 files changed, 355 insertions(+), 256 deletions(-) diff --git a/doc/container.qbk b/doc/container.qbk index 75f4a3f..6e7f9d2 100644 --- a/doc/container.qbk +++ b/doc/container.qbk @@ -614,6 +614,16 @@ use [*Boost.Container]? There are several reasons for that: [section:release_notes Release Notes] +[section:release_notes_boost_1_53_00 Boost 1.53 Release] + +* Improved `vector`'s insertion performance. +* Changed again experimental multiallocation interface for better performance (still experimental). +* Added no exception support for those willing to disable exceptions in their compilers. +* Fixed GCC -Wshadow warnings. +* Replaced deprecated BOOST_NO_XXXX with newer BOOST_NO_CXX11_XXX macros. + +[endsect] + [section:release_notes_boost_1_52_00 Boost 1.52 Release] * Improved `stable_vector`'s template code bloat and type safety. diff --git a/example/doc_move_containers.cpp b/example/doc_move_containers.cpp index c0fa618..867db0b 100644 --- a/example/doc_move_containers.cpp +++ b/example/doc_move_containers.cpp @@ -11,7 +11,7 @@ #include //[doc_move_containers #include -#include +#include #include //Non-copyable class diff --git a/proj/to-do.txt b/proj/to-do.txt index f0c9890..01d497a 100644 --- a/proj/to-do.txt +++ b/proj/to-do.txt @@ -5,6 +5,10 @@ ->Align with C++11 [multi]map::insert(P &&p) overload. ->Unify all allocator version traits in one class (starting from stable_vector_detail::allocator_version_wrapper) maybe in allocator_traits? +->Fix code marked with "//to-do: if possible, an efficient way to deallocate allocated blocks" +->Add BOOST_CONTAINER_TRY, etc. macros to allow disabling exceptions only in this library (just like Boost.Intrusive) +->Add macro to change the default allocator std::allocator to another one +->Add front()/back() to string Review allocator traits @@ -56,97 +60,4 @@ Add hash for containers Add std:: hashing support -Fix trivial destructor after move and other optimizing traits - -Mark previous() in slist/and forward_list as non-standard - -Function order: - -----------type------------ -value_type; -pointer; -const_pointer; -reference; -const_reference; -size_type; -difference_type; -allocator_type; -stored_allocator_type; -iterator; -const_iterator; -reverse_iterator; -const_reverse_iterator; -----------func------------ -container() -container(allocator_type) -container(size_type) -container(size_type, value_type, allocator_type = ()) -container(InpIt, InpIt) -container(const container &) -container(container &&) -container(const container &, allocator_type) -container(container &&, allocator_type) -container(initializer_list, allocator) -~container() -container operator=(const container &) -container operator=(container &&) -container operator=(initializer_list) -assign(size_type, const T &) - -assign(InpIt, InptIt) -assign(initializer_list) -get_allocator() - -begin() -begin() const -end() -end() const -rbegin() -rbegin() const -rend() -rend() const - -cbegin() const -cend() const -crbegin() const -crend() const - -empty() -size() -max_size() -resize(size_type) -resize(size_type, cont T&) -capacity() -reserve(size_type) -shrink_to_fit() - -front() -front() const -back() -back() const -operator[] () -operator[] ()const -at() -at() const - - -data() -data() const - -emplace_front() -emplace_back() -emplace() -push_front(const T&) -push_front(T&&) -push_back(const T&) -push_back(T&&) -insert(iterator, const T &) -insert(iterator, T &&) -insert(size_type, const T &) -insert(InpIt, InpIt) -pop_front() -pop_back() -erase(const_iterator) -erase(const_iterator, const_iterator) -swap(container &) -clear() \ No newline at end of file +Fix trivial destructor after move and other optimizing traits \ No newline at end of file diff --git a/proj/vc7ide/container.vcproj b/proj/vc7ide/container.vcproj index ca5a3e3..5c89b16 100644 --- a/proj/vc7ide/container.vcproj +++ b/proj/vc7ide/container.vcproj @@ -242,6 +242,9 @@ + + diff --git a/test/allocator_traits_test.cpp b/test/allocator_traits_test.cpp index 65ce8f3..3161884 100644 --- a/test/allocator_traits_test.cpp +++ b/test/allocator_traits_test.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include template diff --git a/test/deque_test.cpp b/test/deque_test.cpp index fbc4ab6..23a8e58 100644 --- a/test/deque_test.cpp +++ b/test/deque_test.cpp @@ -21,7 +21,8 @@ #include "check_equal_containers.hpp" #include "dummy_test_allocator.hpp" #include "movable_int.hpp" -#include +#include +#include #include #include #include @@ -148,8 +149,7 @@ bool do_test() MyCntDeque *cntdeque = new MyCntDeque; MyStdDeque *stddeque = new MyStdDeque; //Compare several shared memory deque operations with std::deque - int i; - for(i = 0; i < max*100; ++i){ + for(int i = 0; i < max*100; ++i){ IntType move_me(i); cntdeque->insert(cntdeque->end(), boost::move(move_me)); stddeque->insert(stddeque->end(), i); @@ -159,7 +159,7 @@ bool do_test() cntdeque->clear(); stddeque->clear(); - for(i = 0; i < max*100; ++i){ + for(int i = 0; i < max*100; ++i){ IntType move_me(i); cntdeque->push_back(boost::move(move_me)); stddeque->push_back(i); @@ -169,7 +169,7 @@ bool do_test() cntdeque->clear(); stddeque->clear(); - for(i = 0; i < max*100; ++i){ + for(int i = 0; i < max*100; ++i){ IntType move_me(i); cntdeque->push_front(boost::move(move_me)); stddeque->push_front(i); @@ -239,7 +239,7 @@ bool do_test() if(!test::CheckEqualContainers(cntdeque, stddeque)) return false; - for(i = 0; i < max; ++i){ + for(int i = 0; i < max; ++i){ IntType move_me(i); cntdeque->insert(cntdeque->begin(), boost::move(move_me)); stddeque->insert(stddeque->begin(), i); diff --git a/test/dummy_test_allocator.hpp b/test/dummy_test_allocator.hpp index 332892e..ef95836 100644 --- a/test/dummy_test_allocator.hpp +++ b/test/dummy_test_allocator.hpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include @@ -55,7 +55,7 @@ class simple_allocator {} T* allocate(std::size_t n) - { return (T*)::new char[sizeof(T)*n]; } + { return (T*)::new char[sizeof(T)*n]; } void deallocate(T*p, std::size_t) { delete[] ((char*)p);} @@ -168,8 +168,8 @@ class dummy_test_allocator //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. Memory allocated with this function //!must be deallocated only with deallocate_one(). - multiallocation_chain allocate_individual(size_type) - { return multiallocation_chain(); } + void allocate_individual(size_type, multiallocation_chain &) + {} //!Allocates many elements of size == 1 in a contiguous block //!of memory. The minimum number to be allocated is min_elements, @@ -177,7 +177,7 @@ class dummy_test_allocator //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. Memory allocated with this function //!must be deallocated only with deallocate_one(). - void deallocate_individual(multiallocation_chain) + void deallocate_individual(multiallocation_chain &) {} //!Allocates many elements of size elem_size in a contiguous block @@ -186,7 +186,7 @@ class dummy_test_allocator //!preferred_elements. The number of actually allocated elements is //!will be assigned to received_size. The elements must be deallocated //!with deallocate(...) - void deallocate_many(multiallocation_chain) + void deallocate_many(multiallocation_chain &) {} }; diff --git a/test/emplace_test.hpp b/test/emplace_test.hpp index ff93659..c772c9c 100644 --- a/test/emplace_test.hpp +++ b/test/emplace_test.hpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include @@ -98,14 +98,20 @@ enum EmplaceOptions{ }; template -bool test_expected_container(const Container &ec, const EmplaceInt *Expected, unsigned int only_first_n) +bool test_expected_container(const Container &ec, const EmplaceInt *Expected, unsigned int only_first_n, unsigned int cont_offset = 0) { typedef typename Container::const_iterator const_iterator; const_iterator itb(ec.begin()), ite(ec.end()); unsigned int cur = 0; - if(only_first_n > ec.size()){ + if(cont_offset > ec.size()){ return false; } + if(only_first_n > (ec.size() - cont_offset)){ + return false; + } + while(cont_offset--){ + ++itb; + } for(; itb != ite && only_first_n--; ++itb, ++cur){ const EmplaceInt & cr = *itb; if(cr != Expected[cur]){ @@ -163,33 +169,39 @@ bool test_emplace_back(container_detail::true_) << typeid(Container).name() << std::endl; { - new(&expected [0]) EmplaceInt(); - new(&expected [1]) EmplaceInt(1); - new(&expected [2]) EmplaceInt(1, 2); - new(&expected [3]) EmplaceInt(1, 2, 3); - new(&expected [4]) EmplaceInt(1, 2, 3, 4); - new(&expected [5]) EmplaceInt(1, 2, 3, 4, 5); - Container c; - c.emplace_back(); - if(!test_expected_container(c, &expected[0], 1)) - return false; - c.emplace_back(1); - if(!test_expected_container(c, &expected[0], 2)) - return false; - c.emplace_back(1, 2); - if(!test_expected_container(c, &expected[0], 3)) - return false; - c.emplace_back(1, 2, 3); - if(!test_expected_container(c, &expected[0], 4)) - return false; - c.emplace_back(1, 2, 3, 4); - if(!test_expected_container(c, &expected[0], 5)) - return false; - c.emplace_back(1, 2, 3, 4, 5); - if(!test_expected_container(c, &expected[0], 6)) - return false; + new(&expected [0]) EmplaceInt(); + new(&expected [1]) EmplaceInt(1); + new(&expected [2]) EmplaceInt(1, 2); + new(&expected [3]) EmplaceInt(1, 2, 3); + new(&expected [4]) EmplaceInt(1, 2, 3, 4); + new(&expected [5]) EmplaceInt(1, 2, 3, 4, 5); + Container c; + c.emplace_back(); + if(!test_expected_container(c, &expected[0], 1)){ + return false; + } + c.emplace_back(1); + if(!test_expected_container(c, &expected[0], 2)){ + return false; + } + c.emplace_back(1, 2); + if(!test_expected_container(c, &expected[0], 3)){ + return false; + } + c.emplace_back(1, 2, 3); + if(!test_expected_container(c, &expected[0], 4)){ + return false; + } + c.emplace_back(1, 2, 3, 4); + if(!test_expected_container(c, &expected[0], 5)){ + return false; + } + c.emplace_back(1, 2, 3, 4, 5); + if(!test_expected_container(c, &expected[0], 6)){ + return false; + } } - + std::cout << "...OK" << std::endl; return true; } @@ -212,24 +224,31 @@ bool test_emplace_front(container_detail::true_) new(&expected [5]) EmplaceInt(); Container c; c.emplace_front(); - if(!test_expected_container(c, &expected[0] + 5, 1)) + if(!test_expected_container(c, &expected[0] + 5, 1)){ return false; - c.emplace_front(1);/* - if(!test_expected_container(c, &expected[0] + 4, 2)) + } + c.emplace_front(1); + if(!test_expected_container(c, &expected[0] + 4, 2)){ return false; + } c.emplace_front(1, 2); - if(!test_expected_container(c, &expected[0] + 3, 3)) + if(!test_expected_container(c, &expected[0] + 3, 3)){ return false; + } c.emplace_front(1, 2, 3); - if(!test_expected_container(c, &expected[0] + 2, 4)) + if(!test_expected_container(c, &expected[0] + 2, 4)){ return false; + } c.emplace_front(1, 2, 3, 4); - if(!test_expected_container(c, &expected[0] + 1, 5)) + if(!test_expected_container(c, &expected[0] + 1, 5)){ return false; + } c.emplace_front(1, 2, 3, 4, 5); - if(!test_expected_container(c, &expected[0] + 0, 6)) - return false;*/ + if(!test_expected_container(c, &expected[0] + 0, 6)){ + return false; + } } + std::cout << "...OK" << std::endl; return true; } @@ -250,11 +269,13 @@ bool test_emplace_before(container_detail::true_) Container c; c.emplace(c.cend(), 1); c.emplace(c.cbegin()); - if(!test_expected_container(c, &expected[0], 2)) + if(!test_expected_container(c, &expected[0], 2)){ return false; + } c.emplace(c.cend()); - if(!test_expected_container(c, &expected[0], 3)) + if(!test_expected_container(c, &expected[0], 3)){ return false; + } } { new(&expected [0]) EmplaceInt(); @@ -271,39 +292,74 @@ bool test_emplace_before(container_detail::true_) c.emplace(c.cbegin(), 1, 2); c.emplace(c.cbegin(), 1); c.emplace(c.cbegin()); - if(!test_expected_container(c, &expected[0], 6)) + if(!test_expected_container(c, &expected[0], 6)){ return false; + } c.clear(); //emplace_back-like typename Container::const_iterator i = c.emplace(c.cend()); - if(!test_expected_container(c, &expected[0], 1)) + if(!test_expected_container(c, &expected[0], 1)){ return false; + } i = c.emplace(++i, 1); - if(!test_expected_container(c, &expected[0], 2)) + if(!test_expected_container(c, &expected[0], 2)){ return false; + } i = c.emplace(++i, 1, 2); - if(!test_expected_container(c, &expected[0], 3)) + if(!test_expected_container(c, &expected[0], 3)){ return false; + } i = c.emplace(++i, 1, 2, 3); - if(!test_expected_container(c, &expected[0], 4)) + if(!test_expected_container(c, &expected[0], 4)){ return false; + } i = c.emplace(++i, 1, 2, 3, 4); - if(!test_expected_container(c, &expected[0], 5)) + if(!test_expected_container(c, &expected[0], 5)){ return false; + } i = c.emplace(++i, 1, 2, 3, 4, 5); - if(!test_expected_container(c, &expected[0], 6)) + if(!test_expected_container(c, &expected[0], 6)){ return false; + } c.clear(); //emplace in the middle c.emplace(c.cbegin()); - i = c.emplace(c.cend(), 1, 2, 3, 4, 5); - i = c.emplace(i, 1, 2, 3, 4); - i = c.emplace(i, 1, 2, 3); - i = c.emplace(i, 1, 2); - i = c.emplace(i, 1); - - if(!test_expected_container(c, &expected[0], 6)) + if(!test_expected_container(c, &expected[0], 1)){ return false; + } + i = c.emplace(c.cend(), 1, 2, 3, 4, 5); + if(!test_expected_container(c, &expected[0], 1)){ + return false; + } + if(!test_expected_container(c, &expected[5], 1, 1)){ + return false; + } + i = c.emplace(i, 1, 2, 3, 4); + if(!test_expected_container(c, &expected[0], 1)){ + return false; + } + if(!test_expected_container(c, &expected[4], 2, 1)){ + return false; + } + i = c.emplace(i, 1, 2, 3); + if(!test_expected_container(c, &expected[0], 1)){ + return false; + } + if(!test_expected_container(c, &expected[3], 3, 1)){ + return false; + } + i = c.emplace(i, 1, 2); + if(!test_expected_container(c, &expected[0], 1)){ + return false; + } + if(!test_expected_container(c, &expected[2], 4, 1)){ + return false; + } + i = c.emplace(i, 1); + if(!test_expected_container(c, &expected[0], 6)){ + return false; + } + std::cout << "...OK" << std::endl; } return true; } @@ -324,11 +380,13 @@ bool test_emplace_after(container_detail::true_) Container c; typename Container::const_iterator i = c.emplace_after(c.cbefore_begin(), 1); c.emplace_after(c.cbefore_begin()); - if(!test_expected_container(c, &expected[0], 2)) + if(!test_expected_container(c, &expected[0], 2)){ return false; + } c.emplace_after(i); - if(!test_expected_container(c, &expected[0], 3)) + if(!test_expected_container(c, &expected[0], 3)){ return false; + } } { new(&expected [0]) EmplaceInt(); @@ -345,28 +403,35 @@ bool test_emplace_after(container_detail::true_) c.emplace_after(c.cbefore_begin(), 1, 2); c.emplace_after(c.cbefore_begin(), 1); c.emplace_after(c.cbefore_begin()); - if(!test_expected_container(c, &expected[0], 6)) + if(!test_expected_container(c, &expected[0], 6)){ return false; + } c.clear(); //emplace_back-like typename Container::const_iterator i = c.emplace_after(c.cbefore_begin()); - if(!test_expected_container(c, &expected[0], 1)) + if(!test_expected_container(c, &expected[0], 1)){ return false; + } i = c.emplace_after(i, 1); - if(!test_expected_container(c, &expected[0], 2)) + if(!test_expected_container(c, &expected[0], 2)){ return false; + } i = c.emplace_after(i, 1, 2); - if(!test_expected_container(c, &expected[0], 3)) + if(!test_expected_container(c, &expected[0], 3)){ return false; + } i = c.emplace_after(i, 1, 2, 3); - if(!test_expected_container(c, &expected[0], 4)) + if(!test_expected_container(c, &expected[0], 4)){ return false; + } i = c.emplace_after(i, 1, 2, 3, 4); - if(!test_expected_container(c, &expected[0], 5)) + if(!test_expected_container(c, &expected[0], 5)){ return false; + } i = c.emplace_after(i, 1, 2, 3, 4, 5); - if(!test_expected_container(c, &expected[0], 6)) + if(!test_expected_container(c, &expected[0], 6)){ return false; + } c.clear(); //emplace_after in the middle i = c.emplace_after(c.cbefore_begin()); @@ -376,8 +441,10 @@ bool test_emplace_after(container_detail::true_) c.emplace_after(i, 1, 2); c.emplace_after(i, 1); - if(!test_expected_container(c, &expected[0], 6)) + if(!test_expected_container(c, &expected[0], 6)){ return false; + } + std::cout << "...OK" << std::endl; } return true; } @@ -401,23 +468,30 @@ bool test_emplace_assoc(container_detail::true_) { Container c; c.emplace(); - if(!test_expected_container(c, &expected[0], 1)) + if(!test_expected_container(c, &expected[0], 1)){ return false; + } c.emplace(1); - if(!test_expected_container(c, &expected[0], 2)) + if(!test_expected_container(c, &expected[0], 2)){ return false; + } c.emplace(1, 2); - if(!test_expected_container(c, &expected[0], 3)) + if(!test_expected_container(c, &expected[0], 3)){ return false; + } c.emplace(1, 2, 3); - if(!test_expected_container(c, &expected[0], 4)) + if(!test_expected_container(c, &expected[0], 4)){ return false; + } c.emplace(1, 2, 3, 4); - if(!test_expected_container(c, &expected[0], 5)) + if(!test_expected_container(c, &expected[0], 5)){ return false; + } c.emplace(1, 2, 3, 4, 5); - if(!test_expected_container(c, &expected[0], 6)) + if(!test_expected_container(c, &expected[0], 6)){ return false; + } + std::cout << "...OK" << std::endl; } return true; } @@ -443,23 +517,30 @@ bool test_emplace_hint(container_detail::true_) Container c; typename Container::const_iterator it; it = c.emplace_hint(c.begin()); - if(!test_expected_container(c, &expected[0], 1)) + if(!test_expected_container(c, &expected[0], 1)){ return false; + } it = c.emplace_hint(it, 1); - if(!test_expected_container(c, &expected[0], 2)) + if(!test_expected_container(c, &expected[0], 2)){ return false; + } it = c.emplace_hint(it, 1, 2); - if(!test_expected_container(c, &expected[0], 3)) + if(!test_expected_container(c, &expected[0], 3)){ return false; + } it = c.emplace_hint(it, 1, 2, 3); - if(!test_expected_container(c, &expected[0], 4)) + if(!test_expected_container(c, &expected[0], 4)){ return false; + } it = c.emplace_hint(it, 1, 2, 3, 4); - if(!test_expected_container(c, &expected[0], 5)) + if(!test_expected_container(c, &expected[0], 5)){ return false; + } it = c.emplace_hint(it, 1, 2, 3, 4, 5); - if(!test_expected_container(c, &expected[0], 6)) + if(!test_expected_container(c, &expected[0], 6)){ return false; + } + std::cout << "...OK" << std::endl; } return true; @@ -498,6 +579,7 @@ bool test_emplace_assoc_pair(container_detail::true_) std::cout << "Error after c.emplace(2, 2);\n"; return false; } + std::cout << "...OK" << std::endl; } return true; } @@ -536,6 +618,7 @@ bool test_emplace_hint_pair(container_detail::true_) std::cout << "Error after c.emplace(it, 2, 2);\n"; return false; } + std::cout << "...OK" << std::endl; } return true; } @@ -555,22 +638,30 @@ struct emplace_active template bool test_emplace() { - if(!test_emplace_back(emplace_active())) + if(!test_emplace_back(emplace_active())){ return false; - if(!test_emplace_front(emplace_active())) + } + if(!test_emplace_front(emplace_active())){ return false; - if(!test_emplace_before(emplace_active())) + } + if(!test_emplace_before(emplace_active())){ return false; - if(!test_emplace_after(emplace_active())) + } + if(!test_emplace_after(emplace_active())){ return false; - if(!test_emplace_assoc(emplace_active())) + } + if(!test_emplace_assoc(emplace_active())){ return false; - if(!test_emplace_hint(emplace_active())) + } + if(!test_emplace_hint(emplace_active())){ return false; - if(!test_emplace_assoc_pair(emplace_active())) + } + if(!test_emplace_assoc_pair(emplace_active())){ return false; - if(!test_emplace_hint_pair(emplace_active())) + } + if(!test_emplace_hint_pair(emplace_active())){ return false; + } return true; } diff --git a/test/expand_bwd_test_allocator.hpp b/test/expand_bwd_test_allocator.hpp index fbab8c7..a39aaf1 100644 --- a/test/expand_bwd_test_allocator.hpp +++ b/test/expand_bwd_test_allocator.hpp @@ -65,13 +65,16 @@ class expand_bwd_test_allocator typedef boost::container::container_detail::version_type version; + //Dummy multiallocation chain + struct multiallocation_chain{}; + template struct rebind { typedef expand_bwd_test_allocator other; }; //!Constructor from the segment manager. Never throws - expand_bwd_test_allocator(T *buffer, size_type size, difference_type offset) - : mp_buffer(buffer), m_size(size) + expand_bwd_test_allocator(T *buffer, size_type sz, difference_type offset) + : mp_buffer(buffer), m_size(sz) , m_offset(offset), m_allocations(0){ } //!Constructor from other expand_bwd_test_allocator. Never throws diff --git a/test/flat_tree_test.cpp b/test/flat_tree_test.cpp index c6738e2..c476b13 100644 --- a/test/flat_tree_test.cpp +++ b/test/flat_tree_test.cpp @@ -627,3 +627,77 @@ int main() } #include + +/* +#include +#include +#include +#include +#include + +struct Request +{ + Request() {}; + + //Move semantics... + Request(BOOST_RV_REF(Request) r) : rvals() //Move constructor + { + rvals.swap(r.rvals); + }; + + Request& operator=(BOOST_RV_REF(Request) r) //Move assignment + { + if (this != &r){ + rvals.swap(r.rvals); + } + return *this; + }; + + // Values I want to be moved, not copied. + boost::container::vector rvals; + + private: + // Mark this class movable but not copyable + BOOST_MOVABLE_BUT_NOT_COPYABLE(Request) +}; + +typedef boost::container::flat_map Requests; +//typedef boost::container::map Requests2; + +int +main() { + Requests req; + std::pair ret = req.insert( Requests::value_type( 7, Request() ) ); + std::cout << "Insert success for req: " << ret.second << std::endl; + + //Requests2 req2; + //std::pair ret2 = req2.insert( Requests2::value_type( 7, Request() ) ); + //std::cout << "Insert success for req2: " << ret2.second << std::endl; + + return 0; +} +*/ +/* +#include +#include +#include + +using namespace std; + +int main(int , char *[]) +{ + double d[] = {0, 0.2, 0.8, 1, 2, 3, 4}; + boost::container::flat_set set; + + set.insert(0); + set.insert(set.end(), 1); + set.insert(set.end(), 3); + set.insert(boost::container::ordered_unique_range_t(), d, d + sizeof(d)/sizeof(*d)); + boost::container::flat_set::iterator it(set.begin()); + boost::container::flat_set::iterator const itend(set.end()); + while(it != itend) + cout << *it++ << endl; + + return 0; +} +*/ \ No newline at end of file diff --git a/test/list_test.hpp b/test/list_test.hpp index 85f1b73..e1f0ec6 100644 --- a/test/list_test.hpp +++ b/test/list_test.hpp @@ -19,7 +19,8 @@ #include #include "print_container.hpp" #include "input_from_forward_iterator.hpp" -#include +#include +#include #include namespace boost{ diff --git a/test/map_test.hpp b/test/map_test.hpp index 66dc800..96ea05d 100644 --- a/test/map_test.hpp +++ b/test/map_test.hpp @@ -19,6 +19,8 @@ #include "print_container.hpp" #include #include +#include +#include #include template @@ -104,7 +106,6 @@ int map_test () if(!CheckEqualContainers(boostmap2, stdmap2)) return 1; if(!CheckEqualContainers(boostmultimap2, stdmultimap2)) return 1; -/* MyBoostMap *boostmap3 = new MyBoostMap ( ordered_unique_range , boost::make_move_iterator(&aux_vect[0]) @@ -124,12 +125,14 @@ int map_test () std::cout << "Error in construct(MyBoostMultiMap3)" << std::endl; return 1; } -*/ - IntType i0(0); - boostmap2->erase(i0); - boostmultimap2->erase(i0); - stdmap2->erase(0); - stdmultimap2->erase(0); + + { + IntType i0(0); + boostmap2->erase(i0); + boostmultimap2->erase(i0); + stdmap2->erase(0); + stdmultimap2->erase(0); + } { IntType i0(0); IntType i1(1); @@ -146,10 +149,10 @@ int map_test () delete boostmultimap2; delete stdmap2; delete stdmultimap2; - //delete boostmap3; - //delete boostmultimap3; - //delete stdmap3; - //delete stdmultimap3; + delete boostmap3; + delete boostmultimap3; + delete stdmap3; + delete stdmultimap3; } { //This is really nasty, but we have no other simple choice diff --git a/test/movable_int.hpp b/test/movable_int.hpp index d895845..65fa473 100644 --- a/test/movable_int.hpp +++ b/test/movable_int.hpp @@ -13,7 +13,8 @@ #include #include -#include +#include +#include namespace boost { namespace container { diff --git a/test/scoped_allocator_adaptor_test.cpp b/test/scoped_allocator_adaptor_test.cpp index 66d86b0..1855127 100644 --- a/test/scoped_allocator_adaptor_test.cpp +++ b/test/scoped_allocator_adaptor_test.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include diff --git a/test/scoped_allocator_usage_test.cpp b/test/scoped_allocator_usage_test.cpp index c0a4827..f8dafa4 100644 --- a/test/scoped_allocator_usage_test.cpp +++ b/test/scoped_allocator_usage_test.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include #include diff --git a/test/set_test.hpp b/test/set_test.hpp index 20554df..91397c9 100644 --- a/test/set_test.hpp +++ b/test/set_test.hpp @@ -17,7 +17,8 @@ #include #include #include "print_container.hpp" -#include +#include +#include #include namespace boost{ @@ -119,8 +120,7 @@ int set_test () delete stdmultiset3; } - int i, j; - for(i = 0; i < max; ++i){ + for(int i = 0; i < max; ++i){ IntType move_me(i); boostset->insert(boost::move(move_me)); stdset->insert(i); @@ -301,7 +301,7 @@ int set_test () } } - for(i = 0; i < max; ++i){ + for(int i = 0; i < max; ++i){ IntType move_me(i); boostset->insert(boost::move(move_me)); stdset->insert(i); @@ -319,37 +319,39 @@ int set_test () return 1; } - for(i = 0; i < max; ++i){ - IntType move_me(i); - boostset->insert(boostset->begin(), boost::move(move_me)); - stdset->insert(stdset->begin(), i); - //PrintContainers(boostset, stdset); - IntType move_me2(i); - boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2)); - stdmultiset->insert(stdmultiset->begin(), i); - //PrintContainers(boostmultiset, stdmultiset); - if(!CheckEqualContainers(boostset, stdset)){ - std::cout << "Error in boostset->insert(boostset->begin(), boost::move(move_me))" << std::endl; - return 1; - } - if(!CheckEqualContainers(boostmultiset, stdmultiset)){ - std::cout << "Error in boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2))" << std::endl; - return 1; - } + for(int i = 0; i < max; ++i){ + { + IntType move_me(i); + boostset->insert(boostset->begin(), boost::move(move_me)); + stdset->insert(stdset->begin(), i); + //PrintContainers(boostset, stdset); + IntType move_me2(i); + boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2)); + stdmultiset->insert(stdmultiset->begin(), i); + //PrintContainers(boostmultiset, stdmultiset); + if(!CheckEqualContainers(boostset, stdset)){ + std::cout << "Error in boostset->insert(boostset->begin(), boost::move(move_me))" << std::endl; + return 1; + } + if(!CheckEqualContainers(boostmultiset, stdmultiset)){ + std::cout << "Error in boostmultiset->insert(boostmultiset->begin(), boost::move(move_me2))" << std::endl; + return 1; + } - IntType move_me3(i); - boostset->insert(boostset->end(), boost::move(move_me3)); - stdset->insert(stdset->end(), i); - IntType move_me4(i); - boostmultiset->insert(boostmultiset->end(), boost::move(move_me4)); - stdmultiset->insert(stdmultiset->end(), i); - if(!CheckEqualContainers(boostset, stdset)){ - std::cout << "Error in boostset->insert(boostset->end(), boost::move(move_me3))" << std::endl; - return 1; - } - if(!CheckEqualContainers(boostmultiset, stdmultiset)){ - std::cout << "Error in boostmultiset->insert(boostmultiset->end(), boost::move(move_me4))" << std::endl; - return 1; + IntType move_me3(i); + boostset->insert(boostset->end(), boost::move(move_me3)); + stdset->insert(stdset->end(), i); + IntType move_me4(i); + boostmultiset->insert(boostmultiset->end(), boost::move(move_me4)); + stdmultiset->insert(stdmultiset->end(), i); + if(!CheckEqualContainers(boostset, stdset)){ + std::cout << "Error in boostset->insert(boostset->end(), boost::move(move_me3))" << std::endl; + return 1; + } + if(!CheckEqualContainers(boostmultiset, stdmultiset)){ + std::cout << "Error in boostmultiset->insert(boostmultiset->end(), boost::move(move_me4))" << std::endl; + return 1; + } } { IntType move_me(i); @@ -372,10 +374,11 @@ int set_test () } { IntType move_me(i); + IntType move_me2(i); boostset->insert(boostset->lower_bound(move_me), boost::move(move_me2)); stdset->insert(stdset->lower_bound(i), i); //PrintContainers(boostset, stdset); - IntType move_me2(i); + move_me2 = i; boostmultiset->insert(boostmultiset->lower_bound(move_me2), boost::move(move_me2)); stdmultiset->insert(stdmultiset->lower_bound(i), i); //PrintContainers(boostmultiset, stdmultiset); @@ -391,7 +394,7 @@ int set_test () } //Compare count with std containers - for(i = 0; i < max; ++i){ + for(int i = 0; i < max; ++i){ IntType count_me(i); if(boostset->count(count_me) != stdset->count(i)){ return -1; @@ -407,8 +410,8 @@ int set_test () boostset->clear(); boostmultiset->clear(); - for(j = 0; j < 3; ++j) - for(i = 0; i < 100; ++i){ + for(int j = 0; j < 3; ++j) + for(int i = 0; i < 100; ++i){ IntType move_me(i); boostset->insert(boost::move(move_me)); IntType move_me2(i); @@ -448,8 +451,7 @@ int set_test_copyable () MyBoostMultiSet *boostmultiset = new MyBoostMultiSet; MyStdMultiSet *stdmultiset = new MyStdMultiSet; - int i; - for(i = 0; i < max; ++i){ + for(int i = 0; i < max; ++i){ IntType move_me(i); boostset->insert(boost::move(move_me)); stdset->insert(i); diff --git a/test/string_test.cpp b/test/string_test.cpp index 4b6ff25..f68482d 100644 --- a/test/string_test.cpp +++ b/test/string_test.cpp @@ -330,9 +330,6 @@ int string_test() //Check addition { - typedef std::basic_string StdString; - typedef basic_string BoostString; - BoostString bs2 = string_literals::String(); StdString ss2 = string_literals::String(); BoostString bs3 = string_literals::Suffix(); diff --git a/test/vector_test.cpp b/test/vector_test.cpp index afc03b8..a872315 100644 --- a/test/vector_test.cpp +++ b/test/vector_test.cpp @@ -15,7 +15,7 @@ #include #include -#include +#include #include "check_equal_containers.hpp" #include "movable_int.hpp" #include "expand_bwd_test_allocator.hpp" @@ -148,12 +148,13 @@ int main() v.push_back(Test()); const test::EmplaceOptions Options = (test::EmplaceOptions)(test::EMPLACE_BACK | test::EMPLACE_BEFORE); - if(!boost::container::test::test_emplace - < vector, Options>()) + if(!boost::container::test::test_emplace< vector, Options>()){ return 1; + } - if(!boost::container::test::test_propagate_allocator()) + if(!boost::container::test::test_propagate_allocator()){ return 1; + } return 0; diff --git a/test/vector_test.hpp b/test/vector_test.hpp index 5c262b0..503ec59 100644 --- a/test/vector_test.hpp +++ b/test/vector_test.hpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include "print_container.hpp" #include "check_equal_containers.hpp" @@ -28,6 +28,8 @@ #include #include "emplace_test.hpp" #include "input_from_forward_iterator.hpp" +#include +#include namespace boost{ namespace container {