mirror of
https://github.com/boostorg/container.git
synced 2025-08-02 05:54:28 +02:00
* 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]
This commit is contained in:
@@ -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.
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
//[doc_move_containers
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <cassert>
|
||||
|
||||
//Non-copyable class
|
||||
|
@@ -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<T>, allocator)
|
||||
~container()
|
||||
container operator=(const container &)
|
||||
container operator=(container &&)
|
||||
container operator=(initializer_list<T>)
|
||||
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()
|
||||
Fix trivial destructor after move and other optimizing traits
|
@@ -242,6 +242,9 @@
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\allocation_type.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\allocator_version_traits.hpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\..\..\boost\container\detail\config_begin.hpp">
|
||||
</File>
|
||||
|
@@ -14,7 +14,7 @@
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/container/detail/function_detector.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <memory>
|
||||
|
||||
template<class T>
|
||||
|
@@ -21,7 +21,8 @@
|
||||
#include "check_equal_containers.hpp"
|
||||
#include "dummy_test_allocator.hpp"
|
||||
#include "movable_int.hpp"
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/container/detail/type_traits.hpp>
|
||||
#include <string>
|
||||
@@ -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);
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/container/detail/version_type.hpp>
|
||||
#include <boost/container/detail/multiallocation_chain.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <memory>
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
@@ -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 &)
|
||||
{}
|
||||
};
|
||||
|
||||
|
@@ -15,7 +15,7 @@
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/container/detail/utilities.hpp>
|
||||
#include <boost/aligned_storage.hpp>
|
||||
|
||||
@@ -98,14 +98,20 @@ enum EmplaceOptions{
|
||||
};
|
||||
|
||||
template<class Container>
|
||||
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<class Container, EmplaceOptions O>
|
||||
bool test_emplace()
|
||||
{
|
||||
if(!test_emplace_back<Container>(emplace_active<O, EMPLACE_BACK>()))
|
||||
if(!test_emplace_back<Container>(emplace_active<O, EMPLACE_BACK>())){
|
||||
return false;
|
||||
if(!test_emplace_front<Container>(emplace_active<O, EMPLACE_FRONT>()))
|
||||
}
|
||||
if(!test_emplace_front<Container>(emplace_active<O, EMPLACE_FRONT>())){
|
||||
return false;
|
||||
if(!test_emplace_before<Container>(emplace_active<O, EMPLACE_BEFORE>()))
|
||||
}
|
||||
if(!test_emplace_before<Container>(emplace_active<O, EMPLACE_BEFORE>())){
|
||||
return false;
|
||||
if(!test_emplace_after<Container>(emplace_active<O, EMPLACE_AFTER>()))
|
||||
}
|
||||
if(!test_emplace_after<Container>(emplace_active<O, EMPLACE_AFTER>())){
|
||||
return false;
|
||||
if(!test_emplace_assoc<Container>(emplace_active<O, EMPLACE_ASSOC>()))
|
||||
}
|
||||
if(!test_emplace_assoc<Container>(emplace_active<O, EMPLACE_ASSOC>())){
|
||||
return false;
|
||||
if(!test_emplace_hint<Container>(emplace_active<O, EMPLACE_HINT>()))
|
||||
}
|
||||
if(!test_emplace_hint<Container>(emplace_active<O, EMPLACE_HINT>())){
|
||||
return false;
|
||||
if(!test_emplace_assoc_pair<Container>(emplace_active<O, EMPLACE_ASSOC_PAIR>()))
|
||||
}
|
||||
if(!test_emplace_assoc_pair<Container>(emplace_active<O, EMPLACE_ASSOC_PAIR>())){
|
||||
return false;
|
||||
if(!test_emplace_hint_pair<Container>(emplace_active<O, EMPLACE_HINT_PAIR>()))
|
||||
}
|
||||
if(!test_emplace_hint_pair<Container>(emplace_active<O, EMPLACE_HINT_PAIR>())){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -65,13 +65,16 @@ class expand_bwd_test_allocator
|
||||
|
||||
typedef boost::container::container_detail::version_type<expand_bwd_test_allocator, 2> version;
|
||||
|
||||
//Dummy multiallocation chain
|
||||
struct multiallocation_chain{};
|
||||
|
||||
template<class T2>
|
||||
struct rebind
|
||||
{ typedef expand_bwd_test_allocator<T2> 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
|
||||
|
@@ -627,3 +627,77 @@ int main()
|
||||
}
|
||||
|
||||
#include <boost/container/detail/config_end.hpp>
|
||||
|
||||
/*
|
||||
#include <boost/container/map.hpp>
|
||||
#include <boost/container/flat_map.hpp>
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <iostream>
|
||||
|
||||
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<int> rvals;
|
||||
|
||||
private:
|
||||
// Mark this class movable but not copyable
|
||||
BOOST_MOVABLE_BUT_NOT_COPYABLE(Request)
|
||||
};
|
||||
|
||||
typedef boost::container::flat_map<int, Request> Requests;
|
||||
//typedef boost::container::map<int, Request> Requests2;
|
||||
|
||||
int
|
||||
main() {
|
||||
Requests req;
|
||||
std::pair<Requests::iterator, bool> ret = req.insert( Requests::value_type( 7, Request() ) );
|
||||
std::cout << "Insert success for req: " << ret.second << std::endl;
|
||||
|
||||
//Requests2 req2;
|
||||
//std::pair<Requests::iterator, bool> ret2 = req2.insert( Requests2::value_type( 7, Request() ) );
|
||||
//std::cout << "Insert success for req2: " << ret2.second << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
/*
|
||||
#include <cstdlib>
|
||||
#include <iostream>
|
||||
#include <boost/container/flat_set.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main(int , char *[])
|
||||
{
|
||||
double d[] = {0, 0.2, 0.8, 1, 2, 3, 4};
|
||||
boost::container::flat_set<double> 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<double>::iterator it(set.begin());
|
||||
boost::container::flat_set<double>::iterator const itend(set.end());
|
||||
while(it != itend)
|
||||
cout << *it++ << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
*/
|
@@ -19,7 +19,8 @@
|
||||
#include <functional>
|
||||
#include "print_container.hpp"
|
||||
#include "input_from_forward_iterator.hpp"
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <string>
|
||||
|
||||
namespace boost{
|
||||
|
@@ -19,6 +19,8 @@
|
||||
#include "print_container.hpp"
|
||||
#include <boost/container/detail/utilities.hpp>
|
||||
#include <boost/container/detail/pair.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <string>
|
||||
|
||||
template<class T1, class T2, class T3, class T4>
|
||||
@@ -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<MyBoostMultiMap>(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
|
||||
|
@@ -13,7 +13,8 @@
|
||||
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <boost/container/detail/workaround.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <ostream>
|
||||
|
||||
namespace boost {
|
||||
namespace container {
|
||||
|
@@ -11,7 +11,7 @@
|
||||
#include <boost/container/scoped_allocator_fwd.hpp>
|
||||
#include <cstddef>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#include <boost/container/detail/config_begin.hpp>
|
||||
#include <memory>
|
||||
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/container/deque.hpp>
|
||||
#include <boost/container/list.hpp>
|
||||
|
@@ -17,7 +17,8 @@
|
||||
#include <set>
|
||||
#include <functional>
|
||||
#include "print_container.hpp"
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
#include <string>
|
||||
|
||||
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);
|
||||
|
@@ -330,9 +330,6 @@ int string_test()
|
||||
|
||||
//Check addition
|
||||
{
|
||||
typedef std::basic_string<CharType> StdString;
|
||||
typedef basic_string<CharType> BoostString;
|
||||
|
||||
BoostString bs2 = string_literals<CharType>::String();
|
||||
StdString ss2 = string_literals<CharType>::String();
|
||||
BoostString bs3 = string_literals<CharType>::Suffix();
|
||||
|
@@ -15,7 +15,7 @@
|
||||
#include <functional>
|
||||
|
||||
#include <boost/container/vector.hpp>
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#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<test::EmplaceInt>, Options>())
|
||||
if(!boost::container::test::test_emplace< vector<test::EmplaceInt>, Options>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!boost::container::test::test_propagate_allocator<vector>())
|
||||
if(!boost::container::test::test_propagate_allocator<vector>()){
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
@@ -19,7 +19,7 @@
|
||||
#include <functional>
|
||||
#include <list>
|
||||
|
||||
#include <boost/move/move.hpp>
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/container/detail/mpl.hpp>
|
||||
#include "print_container.hpp"
|
||||
#include "check_equal_containers.hpp"
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <vector>
|
||||
#include "emplace_test.hpp"
|
||||
#include "input_from_forward_iterator.hpp"
|
||||
#include <boost/move/utility.hpp>
|
||||
#include <boost/move/iterator.hpp>
|
||||
|
||||
namespace boost{
|
||||
namespace container {
|
||||
|
Reference in New Issue
Block a user