forked from boostorg/container
Added options to static_vector: throw_on_overflow/alignment
This commit is contained in:
1 parent
e23c57337f
commit
5d96b11fe0
7 files changed
+336
-218
No files matched your search
@@ -501,6 +501,9 @@ struct vector_alloc_holder
|
||||
BOOST_CONTAINER_FORCEINLINE void capacity(const size_type &c) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ BOOST_ASSERT( c <= stored_size_type(-1)); m_capacity = c; }
|
||||
|
||||
static BOOST_CONTAINER_FORCEINLINE void on_capacity_overflow()
|
||||
{ }
|
||||
|
||||
private:
|
||||
void priv_first_allocation(size_type cap)
|
||||
{
|
||||
@@ -631,10 +634,13 @@ struct vector_alloc_holder<Allocator, StoredSizeType, version_0>
|
||||
(this->alloc(), boost::movelib::to_raw_pointer(holder.start()), n, boost::movelib::to_raw_pointer(this->start()));
|
||||
}
|
||||
|
||||
static BOOST_CONTAINER_FORCEINLINE void on_capacity_overflow()
|
||||
{ allocator_type::on_capacity_overflow(); }
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE void priv_first_allocation(size_type cap)
|
||||
{
|
||||
if(cap > allocator_type::internal_capacity){
|
||||
throw_bad_alloc();
|
||||
on_capacity_overflow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -648,20 +654,20 @@ struct vector_alloc_holder<Allocator, StoredSizeType, version_0>
|
||||
{
|
||||
typedef typename real_allocator<value_type, OtherAllocator>::type other_allocator_type;
|
||||
if(this->m_size > other_allocator_type::internal_capacity || x.m_size > allocator_type::internal_capacity){
|
||||
throw_bad_alloc();
|
||||
on_capacity_overflow();
|
||||
}
|
||||
this->priv_deep_swap(x);
|
||||
}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE void swap_resources(vector_alloc_holder &) BOOST_NOEXCEPT_OR_NOTHROW
|
||||
{ //Containers with version 0 allocators can't be moved without moving elements one by one
|
||||
throw_bad_alloc();
|
||||
on_capacity_overflow();
|
||||
}
|
||||
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE void steal_resources(vector_alloc_holder &)
|
||||
{ //Containers with version 0 allocators can't be moved without moving elements one by one
|
||||
throw_bad_alloc();
|
||||
on_capacity_overflow();
|
||||
}
|
||||
|
||||
BOOST_CONTAINER_FORCEINLINE allocator_type &alloc() BOOST_NOEXCEPT_OR_NOTHROW
|
||||
@@ -2327,7 +2333,7 @@ private:
|
||||
template<class FwdIt, class Compare>
|
||||
BOOST_CONTAINER_FORCEINLINE void priv_merge_in_new_buffer(FwdIt, size_type, Compare, version_0)
|
||||
{
|
||||
throw_bad_alloc();
|
||||
alloc_holder_t::on_capacity_overflow();
|
||||
}
|
||||
|
||||
template<class FwdIt, class Compare, class Version>
|
||||
@@ -2407,7 +2413,7 @@ private:
|
||||
{
|
||||
if(!dtl::is_same<typename real_allocator<T, OtherA>::type, allocator_type>::value &&
|
||||
this->capacity() < x.size()){
|
||||
throw_bad_alloc();
|
||||
alloc_holder_t::on_capacity_overflow();
|
||||
}
|
||||
T* const this_start = this->priv_raw_begin();
|
||||
T* const other_start = x.priv_raw_begin();
|
||||
@@ -2459,7 +2465,7 @@ private:
|
||||
{
|
||||
if(!dtl::is_same<typename real_allocator<T, OtherA>::type, allocator_type>::value &&
|
||||
this->capacity() < x.size()){
|
||||
throw_bad_alloc();
|
||||
alloc_holder_t::on_capacity_overflow();
|
||||
}
|
||||
T* const this_start = this->priv_raw_begin();
|
||||
T* const other_start = x.priv_raw_begin();
|
||||
@@ -2528,7 +2534,7 @@ private:
|
||||
}
|
||||
|
||||
void priv_reserve_no_capacity(size_type, version_0)
|
||||
{ throw_bad_alloc(); }
|
||||
{ alloc_holder_t::on_capacity_overflow(); }
|
||||
|
||||
dtl::insert_range_proxy<allocator_type, boost::move_iterator<T*>, T*> priv_dummy_empty_proxy()
|
||||
{
|
||||
@@ -2627,10 +2633,10 @@ private:
|
||||
( vector_iterator_get_ptr(p), 1, dtl::get_insert_value_proxy<T*, allocator_type>(::boost::forward<U>(x)));
|
||||
}
|
||||
|
||||
dtl::insert_copy_proxy<allocator_type, T*> priv_single_insert_proxy(const T &x)
|
||||
BOOST_CONTAINER_FORCEINLINE dtl::insert_copy_proxy<allocator_type, T*> priv_single_insert_proxy(const T &x)
|
||||
{ return dtl::insert_copy_proxy<allocator_type, T*> (x); }
|
||||
|
||||
dtl::insert_move_proxy<allocator_type, T*> priv_single_insert_proxy(BOOST_RV_REF(T) x)
|
||||
BOOST_CONTAINER_FORCEINLINE dtl::insert_move_proxy<allocator_type, T*> priv_single_insert_proxy(BOOST_RV_REF(T) x)
|
||||
{ return dtl::insert_move_proxy<allocator_type, T*> (x); }
|
||||
|
||||
template <class U>
|
||||
@@ -2731,7 +2737,7 @@ private:
|
||||
iterator priv_forward_range_insert_no_capacity
|
||||
(const pointer &pos, const size_type, const InsertionProxy , version_0)
|
||||
{
|
||||
throw_bad_alloc();
|
||||
alloc_holder_t::on_capacity_overflow();
|
||||
return iterator(pos);
|
||||
}
|
||||
|
||||
@@ -2831,7 +2837,7 @@ private:
|
||||
|
||||
if (n > remaining){
|
||||
//This will trigger an error
|
||||
throw_bad_alloc();
|
||||
alloc_holder_t::on_capacity_overflow();
|
||||
}
|
||||
this->priv_forward_range_insert_at_end_expand_forward(n, insert_range_proxy);
|
||||
return this->end();
|
||||
|
||||
Reference in new issue
Block a user