summaryrefslogtreecommitdiff
path: root/boost/container/stable_vector.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/container/stable_vector.hpp')
-rw-r--r--boost/container/stable_vector.hpp354
1 files changed, 183 insertions, 171 deletions
diff --git a/boost/container/stable_vector.hpp b/boost/container/stable_vector.hpp
index 851b5f26e8..d91eccd16e 100644
--- a/boost/container/stable_vector.hpp
+++ b/boost/container/stable_vector.hpp
@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
-// (C) Copyright Ion Gaztanaga 2008-2011. Distributed under the Boost
+// (C) Copyright Ion Gaztanaga 2008-2012. Distributed under the Boost
// Software License, Version 1.0. (See accompanying file
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
@@ -34,7 +34,7 @@
#include <boost/container/detail/utilities.hpp>
#include <boost/container/detail/iterators.hpp>
#include <boost/container/detail/algorithms.hpp>
-#include <boost/container/allocator/allocator_traits.hpp>
+#include <boost/container/allocator_traits.hpp>
#include <boost/intrusive/pointer_traits.hpp>
#include <algorithm>
@@ -78,10 +78,6 @@ struct smart_ptr_type<T*>
{ return ptr;}
};
-template<class Ptr>
-inline typename smart_ptr_type<Ptr>::pointer to_raw_pointer(const Ptr &ptr)
-{ return smart_ptr_type<Ptr>::get(ptr); }
-
template <class C>
class clear_on_destroy
{
@@ -97,7 +93,7 @@ class clear_on_destroy
{
if(do_clear_){
c_.clear();
- c_.clear_pool();
+ c_.clear_pool();
}
}
@@ -110,13 +106,10 @@ class clear_on_destroy
template<class VoidPtr>
struct node_type_base
-{/*
- node_type_base(VoidPtr p)
- : up(p)
- {}*/
+{
node_type_base()
{}
- void set_pointer(VoidPtr p)
+ void set_pointer(const VoidPtr &p)
{ up = p; }
VoidPtr up;
@@ -126,33 +119,10 @@ template<typename VoidPointer, typename T>
struct node_type
: public node_type_base<VoidPointer>
{
- node_type()
- : value()
- {}
-
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
-
- template<class ...Args>
- node_type(Args &&...args)
- : value(boost::forward<Args>(args)...)
- {}
-
- #else //BOOST_CONTAINER_PERFECT_FORWARDING
-
- #define BOOST_PP_LOCAL_MACRO(n) \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- node_type(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- : value(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)) \
- {} \
- //!
- #define BOOST_PP_LOCAL_LIMITS (1, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif//BOOST_CONTAINER_PERFECT_FORWARDING
-
- void set_pointer(VoidPointer p)
- { node_type_base<VoidPointer>::set_pointer(p); }
+ private:
+ node_type();
+ public:
T value;
};
@@ -202,21 +172,21 @@ class iterator
iterator(const iterator<T, T&, typename boost::intrusive::pointer_traits<Pointer>::template rebind_pointer<T>::type>& x)
: pn(x.pn)
{}
-
+
private:
static node_type_ptr_t node_ptr_cast(const void_ptr &p)
{
- return node_type_ptr_t(static_cast<node_type_t*>(stable_vector_detail::to_raw_pointer(p)));
+ return node_type_ptr_t(static_cast<node_type_t*>(container_detail::to_raw_pointer(p)));
}
static const_node_type_ptr_t node_ptr_cast(const const_void_ptr &p)
{
- return const_node_type_ptr_t(static_cast<const node_type_t*>(stable_vector_detail::to_raw_pointer(p)));
+ return const_node_type_ptr_t(static_cast<const node_type_t*>(container_detail::to_raw_pointer(p)));
}
static void_ptr_ptr void_ptr_ptr_cast(const void_ptr &p)
{
- return void_ptr_ptr(static_cast<void_ptr*>(stable_vector_detail::to_raw_pointer(p)));
+ return void_ptr_ptr(static_cast<void_ptr*>(container_detail::to_raw_pointer(p)));
}
reference dereference() const
@@ -238,7 +208,7 @@ class iterator
pointer operator->() const { return pointer(&this->dereference()); }
//Increment / Decrement
- iterator& operator++()
+ iterator& operator++()
{ this->increment(); return *this; }
iterator operator++(int)
@@ -353,35 +323,37 @@ BOOST_JOIN(check_invariant_,__LINE__).touch();
/// @endcond
-//!Originally developed by Joaquin M. Lopez Munoz, stable_vector is std::vector
-//!drop-in replacement implemented as a node container, offering iterator and reference
-//!stability.
+//! Originally developed by Joaquin M. Lopez Munoz, stable_vector is std::vector
+//! drop-in replacement implemented as a node container, offering iterator and reference
+//! stability.
//!
-//!More details taken the author's blog: (<a href="http://bannalia.blogspot.com/2008/09/introducing-stablevector.html" > Introducing stable_vector</a>)
+//! More details taken the author's blog:
+//! (<a href="http://bannalia.blogspot.com/2008/09/introducing-stablevector.html" >
+//! Introducing stable_vector</a>)
//!
-//!We present stable_vector, a fully STL-compliant stable container that provides
-//!most of the features of std::vector except element contiguity.
+//! We present stable_vector, a fully STL-compliant stable container that provides
+//! most of the features of std::vector except element contiguity.
//!
-//!General properties: stable_vector satisfies all the requirements of a container,
-//!a reversible container and a sequence and provides all the optional operations
-//!present in std::vector. Like std::vector, iterators are random access.
-//!stable_vector does not provide element contiguity; in exchange for this absence,
-//!the container is stable, i.e. references and iterators to an element of a stable_vector
-//!remain valid as long as the element is not erased, and an iterator that has been
-//!assigned the return value of end() always remain valid until the destruction of
-//!the associated stable_vector.
+//! General properties: stable_vector satisfies all the requirements of a container,
+//! a reversible container and a sequence and provides all the optional operations
+//! present in std::vector. Like std::vector, iterators are random access.
+//! stable_vector does not provide element contiguity; in exchange for this absence,
+//! the container is stable, i.e. references and iterators to an element of a stable_vector
+//! remain valid as long as the element is not erased, and an iterator that has been
+//! assigned the return value of end() always remain valid until the destruction of
+//! the associated stable_vector.
//!
-//!Operation complexity: The big-O complexities of stable_vector operations match
-//!exactly those of std::vector. In general, insertion/deletion is constant time at
-//!the end of the sequence and linear elsewhere. Unlike std::vector, stable_vector
-//!does not internally perform any value_type destruction, copy or assignment
-//!operations other than those exactly corresponding to the insertion of new
-//!elements or deletion of stored elements, which can sometimes compensate in terms
-//!of performance for the extra burden of doing more pointer manipulation and an
-//!additional allocation per element.
+//! Operation complexity: The big-O complexities of stable_vector operations match
+//! exactly those of std::vector. In general, insertion/deletion is constant time at
+//! the end of the sequence and linear elsewhere. Unlike std::vector, stable_vector
+//! does not internally perform any value_type destruction, copy or assignment
+//! operations other than those exactly corresponding to the insertion of new
+//! elements or deletion of stored elements, which can sometimes compensate in terms
+//! of performance for the extra burden of doing more pointer manipulation and an
+//! additional allocation per element.
//!
-//!Exception safety: As stable_vector does not internally copy elements around, some
-//!operations provide stronger exception safety guarantees than in std::vector:
+//! Exception safety: As stable_vector does not internally copy elements around, some
+//! operations provide stronger exception safety guarantees than in std::vector:
#ifdef BOOST_CONTAINER_DOXYGEN_INVOKED
template <class T, class A = std::allocator<T> >
#else
@@ -426,7 +398,7 @@ class stable_vector
integral_constant<unsigned, 1> allocator_v1;
typedef ::boost::container::container_detail::
integral_constant<unsigned, 2> allocator_v2;
- typedef ::boost::container::container_detail::integral_constant
+ typedef ::boost::container::container_detail::integral_constant
<unsigned, boost::container::container_detail::
version<A>::value> alloc_version;
typedef typename allocator_traits_type::
@@ -509,9 +481,9 @@ class stable_vector
public:
//! <b>Effects</b>: Default constructs a stable_vector.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's default constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
stable_vector()
: internal_data(), impl()
@@ -520,11 +492,11 @@ class stable_vector
}
//! <b>Effects</b>: Constructs a stable_vector taking the allocator as parameter.
- //!
+ //!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- explicit stable_vector(const A& al)
+ explicit stable_vector(const allocator_type& al)
: internal_data(al),impl(al)
{
STABLE_VECTOR_CHECK_INVARIANT;
@@ -535,10 +507,10 @@ class stable_vector
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
explicit stable_vector(size_type n)
- : internal_data(A()),impl(A())
+ : internal_data(),impl()
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
this->resize(n);
@@ -551,9 +523,9 @@ class stable_vector
//!
//! <b>Throws</b>: If allocator_type's default constructor or copy constructor
//! throws or T's default or copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Linear to n.
- stable_vector(size_type n, const T& t, const A& al=A())
+ stable_vector(size_type n, const T& t, const allocator_type& al = allocator_type())
: internal_data(al),impl(al)
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
@@ -570,7 +542,7 @@ class stable_vector
//!
//! <b>Complexity</b>: Linear to the range [first, last).
template <class InputIterator>
- stable_vector(InputIterator first,InputIterator last,const A& al=A())
+ stable_vector(InputIterator first,InputIterator last, const allocator_type& al = allocator_type())
: internal_data(al),impl(al)
{
stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
@@ -582,7 +554,7 @@ class stable_vector
//! <b>Effects</b>: Copy constructs a stable_vector.
//!
//! <b>Postcondition</b>: x == *this.
- //!
+ //!
//! <b>Complexity</b>: Linear to the elements x contains.
stable_vector(const stable_vector& x)
: internal_data(allocator_traits<node_allocator_type>::
@@ -599,7 +571,7 @@ class stable_vector
//! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
stable_vector(BOOST_RV_REF(stable_vector) x)
: internal_data(boost::move(x.node_alloc())), impl(boost::move(x.impl))
@@ -607,6 +579,40 @@ class stable_vector
this->priv_swap_members(x);
}
+ //! <b>Effects</b>: Copy constructs a stable_vector using the specified allocator.
+ //!
+ //! <b>Postcondition</b>: x == *this.
+ //!
+ //! <b>Complexity</b>: Linear to the elements x contains.
+ stable_vector(const stable_vector& x, const allocator_type &a)
+ : internal_data(a), impl(a)
+ {
+ stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
+ this->insert(this->cbegin(), x.begin(), x.end());
+ STABLE_VECTOR_CHECK_INVARIANT;
+ cod.release();
+ }
+
+ //! <b>Effects</b>: Move constructor using the specified allocator.
+ //! Moves mx's resources to *this.
+ //!
+ //! <b>Throws</b>: If allocator_type's copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise
+ stable_vector(BOOST_RV_REF(stable_vector) x, const allocator_type &a)
+ : internal_data(a), impl(a)
+ {
+ if(this->node_alloc() == x.node_alloc()){
+ this->priv_swap_members(x);
+ }
+ else{
+ stable_vector_detail::clear_on_destroy<stable_vector> cod(*this);
+ this->insert(this->cbegin(), x.begin(), x.end());
+ STABLE_VECTOR_CHECK_INVARIANT;
+ cod.release();
+ }
+ }
+
//! <b>Effects</b>: Destroys the stable_vector. All stored values are destroyed
//! and used memory is deallocated.
//!
@@ -616,13 +622,13 @@ class stable_vector
~stable_vector()
{
this->clear();
- clear_pool();
+ clear_pool();
}
//! <b>Effects</b>: Makes *this contain the same elements as x.
//!
- //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
- //! of each of x's elements.
+ //! <b>Postcondition</b>: this->size() == x.size(). *this contains a copy
+ //! of each of x's elements.
//!
//! <b>Throws</b>: If memory allocation throws or T's copy constructor throws.
//!
@@ -705,146 +711,146 @@ class stable_vector
}
//! <b>Effects</b>: Returns a copy of the internal allocator.
- //!
+ //!
//! <b>Throws</b>: If allocator's copy constructor throws.
- //!
+ //!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator()const {return node_alloc();}
+ allocator_type get_allocator()const {return this->node_alloc();}
//! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Non-standard extension.
const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
{ return node_alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
- //!
+ //!
//! <b>Throws</b>: Nothing
- //!
+ //!
//! <b>Complexity</b>: Constant.
- //!
+ //!
//! <b>Note</b>: Non-standard extension.
stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
{ return node_alloc(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator begin()
{ return (impl.empty()) ? end(): iterator(node_ptr_cast(impl.front())) ; }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator begin()const
{ return (impl.empty()) ? cend() : const_iterator(node_ptr_cast(impl.front())) ; }
//! <b>Effects</b>: Returns an iterator to the end of the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
iterator end() {return iterator(get_end_node());}
//! <b>Effects</b>: Returns a const_iterator to the end of the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator end()const {return const_iterator(get_end_node());}
- //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
- //! of the reversed stable_vector.
- //!
+ //! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rbegin() {return reverse_iterator(this->end());}
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed stable_vector.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rbegin()const {return const_reverse_iterator(this->end());}
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
- //! of the reversed stable_vector.
- //!
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reverse_iterator rend() {return reverse_iterator(this->begin());}
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed stable_vector.
- //!
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator rend()const {return const_reverse_iterator(this->begin());}
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cbegin()const {return this->begin();}
//! <b>Effects</b>: Returns a const_iterator to the end of the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_iterator cend()const {return this->end();}
- //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
- //! of the reversed stable_vector.
- //!
+ //! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crbegin()const{return this->rbegin();}
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
- //! of the reversed stable_vector.
- //!
+ //! of the reversed stable_vector.
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reverse_iterator crend()const {return this->rend();}
//! <b>Effects</b>: Returns the number of the elements contained in the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type size() const
{ return impl.empty() ? 0 : (impl.size() - ExtraPointers); }
//! <b>Effects</b>: Returns the largest possible size of the stable_vector.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type max_size() const
{ return impl.max_size() - ExtraPointers; }
//! <b>Effects</b>: Number of elements for which memory has been allocated.
//! capacity() is always greater than or equal to size().
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
size_type capacity() const
{
@@ -859,9 +865,9 @@ class stable_vector
}
//! <b>Effects</b>: Returns true if the stable_vector contains no elements.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
bool empty() const
{ return impl.empty() || impl.size() == ExtraPointers; }
@@ -901,7 +907,7 @@ class stable_vector
//! effect. Otherwise, it is a request for allocation of additional memory.
//! If the request is successful, then capacity() is greater than or equal to
//! n; otherwise, capacity() is unchanged. In either case, size() is unchanged.
- //!
+ //!
//! <b>Throws</b>: If memory allocation allocation throws.
void reserve(size_type n)
{
@@ -909,7 +915,7 @@ class stable_vector
if(n > this->max_size())
throw std::bad_alloc();
- size_type size = this->size();
+ size_type size = this->size();
size_type old_capacity = this->capacity();
if(n > old_capacity){
this->initialize_end_node(n);
@@ -929,31 +935,31 @@ class stable_vector
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a reference to the nth element
+ //! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference operator[](size_type n){return value(impl[n]);}
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a const reference to the nth element
+ //! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference operator[](size_type n)const{return value(impl[n]);}
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a reference to the nth element
+ //! <b>Effects</b>: Returns a reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: std::range_error if n >= size()
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference at(size_type n)
{
@@ -964,11 +970,11 @@ class stable_vector
//! <b>Requires</b>: size() > n.
//!
- //! <b>Effects</b>: Returns a const reference to the nth element
+ //! <b>Effects</b>: Returns a const reference to the nth element
//! from the beginning of the container.
- //!
+ //!
//! <b>Throws</b>: std::range_error if n >= size()
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference at(size_type n)const
{
@@ -981,9 +987,9 @@ class stable_vector
//!
//! <b>Effects</b>: Returns a reference to the first
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference front()
{ return value(impl.front()); }
@@ -992,9 +998,9 @@ class stable_vector
//!
//! <b>Effects</b>: Returns a const reference to the first
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference front()const
{ return value(impl.front()); }
@@ -1003,9 +1009,9 @@ class stable_vector
//!
//! <b>Effects</b>: Returns a reference to the last
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
reference back()
{ return value(*(&impl.back() - ExtraPointers)); }
@@ -1014,9 +1020,9 @@ class stable_vector
//!
//! <b>Effects</b>: Returns a const reference to the last
//! element of the container.
- //!
+ //!
//! <b>Throws</b>: Nothing.
- //!
+ //!
//! <b>Complexity</b>: Constant.
const_reference back()const
{ return value(*(&impl.back() - ExtraPointers)); }
@@ -1027,7 +1033,7 @@ class stable_vector
//! T's copy constructor throws.
//!
//! <b>Complexity</b>: Amortized constant time.
- void push_back(insert_const_ref_type x)
+ void push_back(insert_const_ref_type x)
{ return priv_push_back(x); }
#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1045,7 +1051,7 @@ class stable_vector
//! <b>Throws</b>: If memory allocation throws.
//!
//! <b>Complexity</b>: Amortized constant time.
- void push_back(BOOST_RV_REF(T) t)
+ void push_back(BOOST_RV_REF(T) t)
{ this->insert(end(), boost::move(t)); }
//! <b>Effects</b>: Removes the last element from the stable_vector.
@@ -1064,7 +1070,7 @@ class stable_vector
//!
//! <b>Complexity</b>: If position is end(), amortized constant time
//! Linear time otherwise.
- iterator insert(const_iterator position, insert_const_ref_type x)
+ iterator insert(const_iterator position, insert_const_ref_type x)
{ return this->priv_insert(position, x); }
#if defined(BOOST_NO_RVALUE_REFERENCES) && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1084,7 +1090,7 @@ class stable_vector
//!
//! <b>Complexity</b>: If position is end(), amortized constant time
//! Linear time otherwise.
- iterator insert(const_iterator position, BOOST_RV_REF(T) x)
+ iterator insert(const_iterator position, BOOST_RV_REF(T) x)
{
typedef repeat_iterator<T, difference_type> repeat_it;
typedef boost::move_iterator<repeat_it> repeat_move_it;
@@ -1137,7 +1143,7 @@ class stable_vector
void emplace_back(Args &&...args)
{
typedef emplace_functor<Args...> EmplaceFunctor;
- typedef emplace_iterator<node_type_t, EmplaceFunctor, difference_type> EmplaceIterator;
+ typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;
EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...);
this->insert(this->cend(), EmplaceIterator(ef), EmplaceIterator());
}
@@ -1157,7 +1163,7 @@ class stable_vector
//Just call more general insert(pos, size, value) and return iterator
size_type pos_n = position - cbegin();
typedef emplace_functor<Args...> EmplaceFunctor;
- typedef emplace_iterator<node_type_t, EmplaceFunctor, difference_type> EmplaceIterator;
+ typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator;
EmplaceFunctor &&ef = EmplaceFunctor(boost::forward<Args>(args)...);
this->insert(position, EmplaceIterator(ef), EmplaceIterator());
return iterator(this->begin() + pos_n);
@@ -1172,7 +1178,7 @@ class stable_vector
typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \
BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >) \
EmplaceFunctor; \
- typedef emplace_iterator<node_type_t, EmplaceFunctor, difference_type> EmplaceIterator; \
+ typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator; \
EmplaceFunctor ef BOOST_PP_LPAREN_IF(n) \
BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \
BOOST_PP_RPAREN_IF(n); \
@@ -1186,7 +1192,7 @@ class stable_vector
typedef BOOST_PP_CAT(BOOST_PP_CAT(emplace_functor, n), arg) \
BOOST_PP_EXPR_IF(n, <) BOOST_PP_ENUM_PARAMS(n, P) BOOST_PP_EXPR_IF(n, >) \
EmplaceFunctor; \
- typedef emplace_iterator<node_type_t, EmplaceFunctor, difference_type> EmplaceIterator; \
+ typedef emplace_iterator<value_type, EmplaceFunctor, difference_type> EmplaceIterator; \
EmplaceFunctor ef BOOST_PP_LPAREN_IF(n) \
BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _) \
BOOST_PP_RPAREN_IF(n); \
@@ -1204,7 +1210,7 @@ class stable_vector
//!
//! <b>Throws</b>: Nothing.
//!
- //! <b>Complexity</b>: Linear to the elements between pos and the
+ //! <b>Complexity</b>: Linear to the elements between pos and the
//! last element. Constant if pos is the last element.
iterator erase(const_iterator position)
{
@@ -1482,12 +1488,12 @@ class stable_vector
static node_type_ptr_t node_ptr_cast(const void_ptr &p)
{
- return node_type_ptr_t(static_cast<node_type_t*>(stable_vector_detail::to_raw_pointer(p)));
+ return node_type_ptr_t(static_cast<node_type_t*>(container_detail::to_raw_pointer(p)));
}
static node_type_base_ptr_t node_base_ptr_cast(const void_ptr &p)
{
- return node_type_base_ptr_t(static_cast<node_type_base_t*>(stable_vector_detail::to_raw_pointer(p)));
+ return node_type_base_ptr_t(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p)));
}
static value_type& value(const void_ptr &p)
@@ -1529,7 +1535,9 @@ class stable_vector
{
node_type_ptr_t p = this->allocate_one();
try{
- boost::container::construct_in_place(this->node_alloc(), &*p, it);
+ boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), it);
+ //This does not throw
+ ::new(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p))) node_type_base_t;
p->set_pointer(up);
}
catch(...){
@@ -1573,7 +1581,7 @@ class stable_vector
{
for(; first!=last; ++first){
this->insert(position, *first);
- }
+ }
}
template <class InputIterator>
@@ -1621,7 +1629,9 @@ class stable_vector
p = mem.front();
mem.pop_front();
//This can throw
- boost::container::construct_in_place(this->node_alloc(), &*p, first);
+ boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), first);
+ //This does not throw
+ ::new(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p))) node_type_base_t;
p->set_pointer(void_ptr_ptr(&it[i]));
++first;
it[i] = p;
@@ -1650,7 +1660,9 @@ class stable_vector
break;
}
//This can throw
- boost::container::construct_in_place(this->node_alloc(), &*p, first);
+ boost::container::construct_in_place(this->node_alloc(), container_detail::addressof(p->value), first);
+ //This does not throw
+ ::new(static_cast<node_type_base_t*>(container_detail::to_raw_pointer(p))) node_type_base_t;
p->set_pointer(void_ptr_ptr(&it[i]));
++first;
it[i]=p;
@@ -1680,7 +1692,7 @@ class stable_vector
return false;
}
for(const_impl_iterator it = impl.begin(), it_end = get_last_align(); it != it_end; ++it){
- if(const_void_ptr(node_ptr_cast(*it)->up) !=
+ if(const_void_ptr(node_ptr_cast(*it)->up) !=
const_void_ptr(const_void_ptr_ptr(&*it)))
return false;
}