summaryrefslogtreecommitdiff
path: root/boost/container/vector.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:41:18 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-10-06 10:43:11 +0900
commitf763a99a501650eff2c60288aa6f10ef916d769e (patch)
tree02af7e13f9a38c888ebf340fe764cbe7dae99da9 /boost/container/vector.hpp
parent5cde13f21d36c7224b0e13d11c4b49379ae5210d (diff)
downloadboost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.gz
boost-f763a99a501650eff2c60288aa6f10ef916d769e.tar.bz2
boost-f763a99a501650eff2c60288aa6f10ef916d769e.zip
Imported Upstream version 1.62.0upstream/1.62.0
Change-Id: I9d4c1ddb7b7d8f0069217ecc582700f9fda6dd4c Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/container/vector.hpp')
-rw-r--r--boost/container/vector.hpp33
1 files changed, 18 insertions, 15 deletions
diff --git a/boost/container/vector.hpp b/boost/container/vector.hpp
index fabe92df88..5d4ab308ca 100644
--- a/boost/container/vector.hpp
+++ b/boost/container/vector.hpp
@@ -380,7 +380,7 @@ struct vector_alloc_holder
, m_capacity()
{
if(initial_size){
- pointer reuse = 0;
+ pointer reuse = pointer();
m_start = this->allocation_command(allocate_new, initial_size, m_capacity = initial_size, reuse);
}
}
@@ -393,7 +393,7 @@ struct vector_alloc_holder
, m_capacity()
{
if(initial_size){
- pointer reuse = 0;
+ pointer reuse = pointer();
m_start = this->allocation_command(allocate_new, initial_size, m_capacity = initial_size, reuse);
}
}
@@ -525,7 +525,7 @@ struct vector_alloc_holder
void priv_first_allocation(size_type cap)
{
if(cap){
- pointer reuse = 0;
+ pointer reuse = pointer();
m_start = this->allocation_command(allocate_new, cap, cap, reuse);
m_capacity = cap;
#ifdef BOOST_CONTAINER_VECTOR_ALLOC_STATS
@@ -792,7 +792,7 @@ class vector
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- vector() BOOST_NOEXCEPT_OR_NOTHROW
+ vector() BOOST_NOEXCEPT_IF(container_detail::is_nothrow_default_constructible<Allocator>::value)
: m_holder()
{}
@@ -1103,7 +1103,7 @@ class vector
//! this->get>allocator() == x.get_allocator(). Linear otherwise.
BOOST_CONTAINER_FORCEINLINE vector& operator=(BOOST_RV_REF(vector) x)
BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
- || allocator_traits_type::is_always_equal::value)
+ || allocator_traits_type::is_always_equal::value)
{
BOOST_ASSERT(&x != this);
this->priv_move_assign(boost::move(x));
@@ -1630,11 +1630,10 @@ class vector
return const_iterator(this->m_holder.start()+n);
}
- //! <b>Requires</b>: size() >= n.
+ //! <b>Requires</b>: begin() <= p <= end().
//!
- //! <b>Effects</b>: Returns an iterator to the nth element
- //! from the beginning of the container. Returns end()
- //! if n == size().
+ //! <b>Effects</b>: Returns the index of the element pointed by p
+ //! and size() if p == end().
//!
//! <b>Throws</b>: Nothing.
//!
@@ -1725,21 +1724,24 @@ class vector
//! <b>Effects</b>: Inserts an object of type T constructed with
//! std::forward<Args>(args)... in the end of the vector.
//!
+ //! <b>Returns</b>: A reference to the created object.
+ //!
//! <b>Throws</b>: If memory allocation throws or the in-place constructor throws or
//! T's copy/move constructor throws.
//!
//! <b>Complexity</b>: Amortized constant time.
template<class ...Args>
- BOOST_CONTAINER_FORCEINLINE void emplace_back(BOOST_FWD_REF(Args)...args)
+ BOOST_CONTAINER_FORCEINLINE reference emplace_back(BOOST_FWD_REF(Args)...args)
{
if (BOOST_LIKELY(this->room_enough())){
//There is more memory, just construct a new object at the end
allocator_traits_type::construct(this->m_holder.alloc(), this->priv_raw_end(), ::boost::forward<Args>(args)...);
++this->m_holder.m_size;
+ return *this->priv_raw_end();
}
else{
typedef container_detail::insert_emplace_proxy<Allocator, T*, Args...> type;
- this->priv_forward_range_insert_no_capacity
+ return *this->priv_forward_range_insert_no_capacity
(this->back_ptr(), 1, type(::boost::forward<Args>(args)...), alloc_version());
}
}
@@ -1788,16 +1790,17 @@ class vector
#define BOOST_CONTAINER_VECTOR_EMPLACE_CODE(N) \
BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N \
- BOOST_CONTAINER_FORCEINLINE void emplace_back(BOOST_MOVE_UREF##N)\
+ BOOST_CONTAINER_FORCEINLINE reference emplace_back(BOOST_MOVE_UREF##N)\
{\
if (BOOST_LIKELY(this->room_enough())){\
allocator_traits_type::construct (this->m_holder.alloc()\
, this->priv_raw_end() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
++this->m_holder.m_size;\
+ return *this->priv_raw_end();\
}\
else{\
typedef container_detail::insert_emplace_proxy_arg##N<Allocator, T* BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\
- this->priv_forward_range_insert_no_capacity\
+ return *this->priv_forward_range_insert_no_capacity\
( this->back_ptr(), 1, type(BOOST_MOVE_FWD##N), alloc_version());\
}\
}\
@@ -2247,7 +2250,7 @@ class vector
size_type *indexes = 0;
while(remaining){
//Query for room to store indexes in the remaining buffer
- uintptr_t const szt_align_mask = container_detail::alignment_of<size_type>::value - 1;
+ boost::uintptr_t const szt_align_mask = container_detail::alignment_of<size_type>::value - 1;
boost::uintptr_t const addr = boost::uintptr_t(this->priv_raw_begin() + s + n);
boost::uintptr_t const capaddr = boost::uintptr_t(this->priv_raw_begin() + c);
boost::uintptr_t const aligned_addr = (addr + szt_align_mask) & ~szt_align_mask;
@@ -2544,7 +2547,7 @@ class vector
//buffer or expand the old one.
bool same_buffer_start;
size_type real_cap = 0;
- pointer reuse = 0;
+ pointer reuse(this->m_holder.start());
pointer const ret(this->m_holder.allocation_command(allocate_new | expand_fwd | expand_bwd, new_cap, real_cap = new_cap, reuse));
//Check for forward expansion