forked from boostorg/container
Default initialization for vector-like containers
Complexity guarantees for associative container constructors and ordered input ranges Added benchmark for associative containers Fixes #9166 [SVN r85964]
This commit is contained in:
@@ -25,6 +25,12 @@ class SimpleAllocator
|
||||
public:
|
||||
typedef T value_type;
|
||||
|
||||
template <class U>
|
||||
SimpleAllocator(SimpleAllocator<U>)
|
||||
: allocate_called_(false)
|
||||
, deallocate_called_(false)
|
||||
{}
|
||||
|
||||
SimpleAllocator()
|
||||
: allocate_called_(false)
|
||||
, deallocate_called_(false)
|
||||
@@ -132,6 +138,13 @@ class ComplexAllocator
|
||||
#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
|
||||
#include BOOST_PP_LOCAL_ITERATE()
|
||||
|
||||
template<class U>
|
||||
void construct(U *p, boost::container::default_init_t)
|
||||
{
|
||||
construct_called_ = true;
|
||||
::new (p) U;
|
||||
}
|
||||
|
||||
//getters
|
||||
bool allocate_called() const
|
||||
{ return allocate_called_; }
|
||||
@@ -157,13 +170,13 @@ class ComplexAllocator
|
||||
|
||||
class copymovable
|
||||
{
|
||||
bool copymoveconstructed_;
|
||||
bool moved_;
|
||||
|
||||
BOOST_COPYABLE_AND_MOVABLE(copymovable)
|
||||
|
||||
public:
|
||||
|
||||
bool copymoveconstructed_;
|
||||
bool moved_;
|
||||
|
||||
copymovable(int, int, int)
|
||||
: copymoveconstructed_(false), moved_(false)
|
||||
{}
|
||||
@@ -314,6 +327,22 @@ int main()
|
||||
SAllocTraits::select_on_container_copy_construction(s_alloc);
|
||||
|
||||
//construct
|
||||
{
|
||||
copymovable c;
|
||||
c.copymoveconstructed_ = true;
|
||||
c.copymoveconstructed_ = true;
|
||||
CAllocTraits::construct(c_alloc, &c);
|
||||
if(!c_alloc.construct_called() || c.copymoveconstructed() || c.moved()){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
{
|
||||
int i = 5;
|
||||
CAllocTraits::construct(c_alloc, &i, boost::container::default_init);
|
||||
if(!c_alloc.construct_called() || i != 5){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
{
|
||||
copymovable c;
|
||||
copymovable c2;
|
||||
@@ -330,6 +359,22 @@ int main()
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
{
|
||||
copymovable c;
|
||||
c.copymoveconstructed_ = true;
|
||||
c.copymoveconstructed_ = true;
|
||||
SAllocTraits::construct(s_alloc, &c);
|
||||
if(c.copymoveconstructed() || c.moved()){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
{
|
||||
int i = 4;
|
||||
SAllocTraits::construct(s_alloc, &i, boost::container::default_init);
|
||||
if(i != 4){
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
{
|
||||
copymovable c;
|
||||
copymovable c2;
|
||||
|
||||
Reference in New Issue
Block a user