summaryrefslogtreecommitdiff
path: root/boost/container/deque.hpp
diff options
context:
space:
mode:
authorDongHun Kwak <dh0128.kwak@samsung.com>2016-03-21 15:45:20 +0900
committerDongHun Kwak <dh0128.kwak@samsung.com>2016-03-21 15:46:37 +0900
commit733b5d5ae2c5d625211e2985ac25728ac3f54883 (patch)
treea5b214744b256f07e1dc2bd7273035a7808c659f /boost/container/deque.hpp
parent08c1e93fa36a49f49325a07fe91ff92c964c2b6c (diff)
downloadboost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.gz
boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.tar.bz2
boost-733b5d5ae2c5d625211e2985ac25728ac3f54883.zip
Imported Upstream version 1.58.0upstream/1.58.0
Change-Id: If0072143aa26874812e0db6872e1efb10a3e5e94 Signed-off-by: DongHun Kwak <dh0128.kwak@samsung.com>
Diffstat (limited to 'boost/container/deque.hpp')
-rw-r--r--boost/container/deque.hpp569
1 files changed, 334 insertions, 235 deletions
diff --git a/boost/container/deque.hpp b/boost/container/deque.hpp
index d8a546c86f..eb372a430a 100644
--- a/boost/container/deque.hpp
+++ b/boost/container/deque.hpp
@@ -7,42 +7,51 @@
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
-
#ifndef BOOST_CONTAINER_DEQUE_HPP
#define BOOST_CONTAINER_DEQUE_HPP
-#if defined(_MSC_VER)
+#ifndef BOOST_CONFIG_HPP
+# include <boost/config.hpp>
+#endif
+
+#if defined(BOOST_HAS_PRAGMA_ONCE)
# pragma once
#endif
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/detail/workaround.hpp>
-
-#include <boost/container/detail/utilities.hpp>
-#include <boost/container/detail/iterators.hpp>
-#include <boost/container/detail/algorithms.hpp>
-#include <boost/container/detail/mpl.hpp>
+// container
#include <boost/container/allocator_traits.hpp>
#include <boost/container/container_fwd.hpp>
+#include <boost/container/new_allocator.hpp> //new_allocator
#include <boost/container/throw_exception.hpp>
-#include <cstddef>
-#include <iterator>
-#include <boost/assert.hpp>
-#include <memory>
-#include <algorithm>
-#include <boost/core/no_exceptions_support.hpp>
-#include <boost/type_traits/has_trivial_destructor.hpp>
-#include <boost/type_traits/has_trivial_copy.hpp>
-#include <boost/type_traits/has_trivial_assign.hpp>
-#include <boost/type_traits/has_nothrow_copy.hpp>
-#include <boost/type_traits/has_nothrow_assign.hpp>
-#include <boost/move/utility_core.hpp>
+// container/detail
+#include <boost/container/detail/advanced_insert_int.hpp>
+#include <boost/container/detail/algorithm.hpp> //algo_equal(), algo_lexicographical_compare
+#include <boost/container/detail/alloc_helpers.hpp>
+#include <boost/container/detail/copy_move_algo.hpp>
+#include <boost/container/detail/iterator.hpp>
+#include <boost/container/detail/iterator_to_raw_pointer.hpp>
+#include <boost/container/detail/iterators.hpp>
+#include <boost/container/detail/min_max.hpp>
+#include <boost/container/detail/mpl.hpp>
+#include <boost/container/detail/to_raw_pointer.hpp>
+#include <boost/container/detail/type_traits.hpp>
+// move
+#include <boost/move/adl_move_swap.hpp>
#include <boost/move/iterator.hpp>
-#include <boost/move/algorithm.hpp>
-#include <boost/move/detail/move_helpers.hpp>
#include <boost/move/traits.hpp>
-#include <boost/container/detail/advanced_insert_int.hpp>
+#include <boost/move/utility_core.hpp>
+// move/detail
+#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+#include <boost/move/detail/fwd_macros.hpp>
+#endif
+#include <boost/move/detail/move_helpers.hpp>
+// other
+#include <boost/assert.hpp>
#include <boost/core/no_exceptions_support.hpp>
+// std
+#include <cstddef>
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
@@ -59,13 +68,8 @@ template <class T>
struct deque_value_traits
{
typedef T value_type;
- static const bool trivial_dctr = boost::has_trivial_destructor<value_type>::value;
+ static const bool trivial_dctr = container_detail::is_trivially_destructible<value_type>::value;
static const bool trivial_dctr_after_move = ::boost::has_trivial_destructor_after_move<value_type>::value;
- static const bool trivial_copy = has_trivial_copy<value_type>::value;
- static const bool nothrow_copy = has_nothrow_copy<value_type>::value;
- static const bool trivial_assign = has_trivial_assign<value_type>::value;
- //static const bool nothrow_assign = has_nothrow_assign<value_type>::value;
- static const bool nothrow_assign = false;
};
// Note: this function is simply a kludge to work around several compilers'
@@ -102,7 +106,7 @@ namespace container_detail {
// [map, map + map_size) is a valid, non-empty range.
// [start.node, finish.node] is a valid range contained within
// [map, map + map_size).
-// Allocator pointer in the range [map, map + map_size) points to an allocated node
+// A pointer in the range [map, map + map_size) points to an allocated node
// if and only if the pointer is in the range [start.node, finish.node].
template<class Pointer, bool IsConst>
class deque_iterator
@@ -142,34 +146,34 @@ class deque_iterator
Pointer get_last() const { return m_last; }
index_pointer get_node() const { return m_node; }
- deque_iterator(val_alloc_ptr x, index_pointer y) BOOST_CONTAINER_NOEXCEPT
+ deque_iterator(val_alloc_ptr x, index_pointer y) BOOST_NOEXCEPT_OR_NOTHROW
: m_cur(x), m_first(*y), m_last(*y + s_buffer_size()), m_node(y)
{}
- deque_iterator() BOOST_CONTAINER_NOEXCEPT
+ deque_iterator() BOOST_NOEXCEPT_OR_NOTHROW
: m_cur(), m_first(), m_last(), m_node() //Value initialization to achieve "null iterators" (N3644)
{}
- deque_iterator(deque_iterator<Pointer, false> const& x) BOOST_CONTAINER_NOEXCEPT
+ deque_iterator(deque_iterator<Pointer, false> const& x) BOOST_NOEXCEPT_OR_NOTHROW
: m_cur(x.get_cur()), m_first(x.get_first()), m_last(x.get_last()), m_node(x.get_node())
{}
- deque_iterator(Pointer cur, Pointer first, Pointer last, index_pointer node) BOOST_CONTAINER_NOEXCEPT
+ deque_iterator(Pointer cur, Pointer first, Pointer last, index_pointer node) BOOST_NOEXCEPT_OR_NOTHROW
: m_cur(cur), m_first(first), m_last(last), m_node(node)
{}
- deque_iterator<Pointer, false> unconst() const BOOST_CONTAINER_NOEXCEPT
+ deque_iterator<Pointer, false> unconst() const BOOST_NOEXCEPT_OR_NOTHROW
{
return deque_iterator<Pointer, false>(this->get_cur(), this->get_first(), this->get_last(), this->get_node());
}
- reference operator*() const BOOST_CONTAINER_NOEXCEPT
+ reference operator*() const BOOST_NOEXCEPT_OR_NOTHROW
{ return *this->m_cur; }
- pointer operator->() const BOOST_CONTAINER_NOEXCEPT
+ pointer operator->() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->m_cur; }
- difference_type operator-(const deque_iterator& x) const BOOST_CONTAINER_NOEXCEPT
+ difference_type operator-(const deque_iterator& x) const BOOST_NOEXCEPT_OR_NOTHROW
{
if(!this->m_cur && !x.m_cur){
return 0;
@@ -178,7 +182,7 @@ class deque_iterator
(this->m_cur - this->m_first) + (x.m_last - x.m_cur);
}
- deque_iterator& operator++() BOOST_CONTAINER_NOEXCEPT
+ deque_iterator& operator++() BOOST_NOEXCEPT_OR_NOTHROW
{
++this->m_cur;
if (this->m_cur == this->m_last) {
@@ -188,14 +192,14 @@ class deque_iterator
return *this;
}
- deque_iterator operator++(int) BOOST_CONTAINER_NOEXCEPT
+ deque_iterator operator++(int) BOOST_NOEXCEPT_OR_NOTHROW
{
deque_iterator tmp(*this);
++*this;
return tmp;
}
- deque_iterator& operator--() BOOST_CONTAINER_NOEXCEPT
+ deque_iterator& operator--() BOOST_NOEXCEPT_OR_NOTHROW
{
if (this->m_cur == this->m_first) {
this->priv_set_node(this->m_node - 1);
@@ -205,14 +209,14 @@ class deque_iterator
return *this;
}
- deque_iterator operator--(int) BOOST_CONTAINER_NOEXCEPT
+ deque_iterator operator--(int) BOOST_NOEXCEPT_OR_NOTHROW
{
deque_iterator tmp(*this);
--*this;
return tmp;
}
- deque_iterator& operator+=(difference_type n) BOOST_CONTAINER_NOEXCEPT
+ deque_iterator& operator+=(difference_type n) BOOST_NOEXCEPT_OR_NOTHROW
{
difference_type offset = n + (this->m_cur - this->m_first);
if (offset >= 0 && offset < difference_type(this->s_buffer_size()))
@@ -228,44 +232,44 @@ class deque_iterator
return *this;
}
- deque_iterator operator+(difference_type n) const BOOST_CONTAINER_NOEXCEPT
+ deque_iterator operator+(difference_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{ deque_iterator tmp(*this); return tmp += n; }
- deque_iterator& operator-=(difference_type n) BOOST_CONTAINER_NOEXCEPT
+ deque_iterator& operator-=(difference_type n) BOOST_NOEXCEPT_OR_NOTHROW
{ return *this += -n; }
- deque_iterator operator-(difference_type n) const BOOST_CONTAINER_NOEXCEPT
+ deque_iterator operator-(difference_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{ deque_iterator tmp(*this); return tmp -= n; }
- reference operator[](difference_type n) const BOOST_CONTAINER_NOEXCEPT
+ reference operator[](difference_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{ return *(*this + n); }
- friend bool operator==(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT
+ friend bool operator==(const deque_iterator& l, const deque_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return l.m_cur == r.m_cur; }
- friend bool operator!=(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT
+ friend bool operator!=(const deque_iterator& l, const deque_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return l.m_cur != r.m_cur; }
- friend bool operator<(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT
+ friend bool operator<(const deque_iterator& l, const deque_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return (l.m_node == r.m_node) ? (l.m_cur < r.m_cur) : (l.m_node < r.m_node); }
- friend bool operator>(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT
+ friend bool operator>(const deque_iterator& l, const deque_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return r < l; }
- friend bool operator<=(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT
+ friend bool operator<=(const deque_iterator& l, const deque_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return !(r < l); }
- friend bool operator>=(const deque_iterator& l, const deque_iterator& r) BOOST_CONTAINER_NOEXCEPT
+ friend bool operator>=(const deque_iterator& l, const deque_iterator& r) BOOST_NOEXCEPT_OR_NOTHROW
{ return !(l < r); }
- void priv_set_node(index_pointer new_node) BOOST_CONTAINER_NOEXCEPT
+ void priv_set_node(index_pointer new_node) BOOST_NOEXCEPT_OR_NOTHROW
{
this->m_node = new_node;
this->m_first = *new_node;
this->m_last = this->m_first + this->s_buffer_size();
}
- friend deque_iterator operator+(difference_type n, deque_iterator x) BOOST_CONTAINER_NOEXCEPT
+ friend deque_iterator operator+(difference_type n, deque_iterator x) BOOST_NOEXCEPT_OR_NOTHROW
{ return x += n; }
};
@@ -304,19 +308,19 @@ class deque_base
typedef deque_value_traits<val_alloc_val> traits_t;
typedef ptr_alloc_t map_allocator_type;
- static size_type s_buffer_size() BOOST_CONTAINER_NOEXCEPT
+ static size_type s_buffer_size() BOOST_NOEXCEPT_OR_NOTHROW
{ return deque_buf_size<val_alloc_val>::value; }
val_alloc_ptr priv_allocate_node()
{ return this->alloc().allocate(s_buffer_size()); }
- void priv_deallocate_node(val_alloc_ptr p) BOOST_CONTAINER_NOEXCEPT
+ void priv_deallocate_node(val_alloc_ptr p) BOOST_NOEXCEPT_OR_NOTHROW
{ this->alloc().deallocate(p, s_buffer_size()); }
ptr_alloc_ptr priv_allocate_map(size_type n)
{ return this->ptr_alloc().allocate(n); }
- void priv_deallocate_map(ptr_alloc_ptr p, size_type n) BOOST_CONTAINER_NOEXCEPT
+ void priv_deallocate_map(ptr_alloc_ptr p, size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{ this->ptr_alloc().deallocate(p, n); }
typedef container_detail::deque_iterator<val_alloc_ptr, false> iterator;
@@ -352,12 +356,12 @@ class deque_base
protected:
- void swap_members(deque_base &x) BOOST_CONTAINER_NOEXCEPT
+ void swap_members(deque_base &x) BOOST_NOEXCEPT_OR_NOTHROW
{
- std::swap(this->members_.m_start, x.members_.m_start);
- std::swap(this->members_.m_finish, x.members_.m_finish);
- std::swap(this->members_.m_map, x.members_.m_map);
- std::swap(this->members_.m_map_size, x.members_.m_map_size);
+ ::boost::adl_move_swap(this->members_.m_start, x.members_.m_start);
+ ::boost::adl_move_swap(this->members_.m_finish, x.members_.m_finish);
+ ::boost::adl_move_swap(this->members_.m_map, x.members_.m_map);
+ ::boost::adl_move_swap(this->members_.m_map_size, x.members_.m_map_size);
}
void priv_initialize_map(size_type num_elements)
@@ -392,9 +396,9 @@ class deque_base
void priv_create_nodes(ptr_alloc_ptr nstart, ptr_alloc_ptr nfinish)
{
- ptr_alloc_ptr cur;
+ ptr_alloc_ptr cur = nstart;
BOOST_TRY {
- for (cur = nstart; cur < nfinish; ++cur)
+ for (; cur < nfinish; ++cur)
*cur = this->priv_allocate_node();
}
BOOST_CATCH(...){
@@ -404,13 +408,13 @@ class deque_base
BOOST_CATCH_END
}
- void priv_destroy_nodes(ptr_alloc_ptr nstart, ptr_alloc_ptr nfinish) BOOST_CONTAINER_NOEXCEPT
+ void priv_destroy_nodes(ptr_alloc_ptr nstart, ptr_alloc_ptr nfinish) BOOST_NOEXCEPT_OR_NOTHROW
{
for (ptr_alloc_ptr n = nstart; n < nfinish; ++n)
this->priv_deallocate_node(*n);
}
- void priv_clear_map() BOOST_CONTAINER_NOEXCEPT
+ void priv_clear_map() BOOST_NOEXCEPT_OR_NOTHROW
{
if (this->members_.m_map) {
this->priv_destroy_nodes(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1);
@@ -455,16 +459,16 @@ class deque_base
iterator m_finish;
} members_;
- ptr_alloc_t &ptr_alloc() BOOST_CONTAINER_NOEXCEPT
+ ptr_alloc_t &ptr_alloc() BOOST_NOEXCEPT_OR_NOTHROW
{ return members_; }
- const ptr_alloc_t &ptr_alloc() const BOOST_CONTAINER_NOEXCEPT
+ const ptr_alloc_t &ptr_alloc() const BOOST_NOEXCEPT_OR_NOTHROW
{ return members_; }
- allocator_type &alloc() BOOST_CONTAINER_NOEXCEPT
+ allocator_type &alloc() BOOST_NOEXCEPT_OR_NOTHROW
{ return members_; }
- const allocator_type &alloc() const BOOST_CONTAINER_NOEXCEPT
+ const allocator_type &alloc() const BOOST_NOEXCEPT_OR_NOTHROW
{ return members_; }
};
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
@@ -475,7 +479,7 @@ class deque_base
//!
//! \tparam T The type of object that is stored in the deque
//! \tparam Allocator The allocator used for all internal memory management
-template <class T, class Allocator = std::allocator<T> >
+template <class T, class Allocator = new_allocator<T> >
#else
template <class T, class Allocator>
#endif
@@ -505,8 +509,8 @@ class deque : protected deque_base<Allocator>
typedef BOOST_CONTAINER_IMPDEF(allocator_type) stored_allocator_type;
typedef BOOST_CONTAINER_IMPDEF(typename Base::iterator) iterator;
typedef BOOST_CONTAINER_IMPDEF(typename Base::const_iterator) const_iterator;
- typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator<iterator>) reverse_iterator;
- typedef BOOST_CONTAINER_IMPDEF(container_detail::reverse_iterator<const_iterator>) const_reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<iterator>) reverse_iterator;
+ typedef BOOST_CONTAINER_IMPDEF(boost::container::reverse_iterator<const_iterator>) const_reverse_iterator;
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
@@ -540,11 +544,11 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing
//!
//! <b>Complexity</b>: Constant.
- explicit deque(const allocator_type& a) BOOST_CONTAINER_NOEXCEPT
+ explicit deque(const allocator_type& a) BOOST_NOEXCEPT_OR_NOTHROW
: Base(a)
{}
- //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
+ //! <b>Effects</b>: Constructs a deque
//! and inserts n value initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor
@@ -559,7 +563,7 @@ class deque : protected deque_base<Allocator>
//deque_base will deallocate in case of exception...
}
- //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
+ //! <b>Effects</b>: Constructs a deque
//! and inserts n default initialized values.
//!
//! <b>Throws</b>: If allocator_type's default constructor
@@ -577,6 +581,38 @@ class deque : protected deque_base<Allocator>
}
//! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
+ //! and inserts n value initialized values.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor
+ //! throws or T's value initialization throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ explicit deque(size_type n, const allocator_type &a)
+ : Base(n, a)
+ {
+ container_detail::insert_value_initialized_n_proxy<Allocator, iterator> proxy;
+ proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n);
+ //deque_base will deallocate in case of exception...
+ }
+
+ //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
+ //! and inserts n default initialized values.
+ //!
+ //! <b>Throws</b>: If allocator_type's default constructor
+ //! throws or T's default initialization or copy constructor throws.
+ //!
+ //! <b>Complexity</b>: Linear to n.
+ //!
+ //! <b>Note</b>: Non-standard extension
+ deque(size_type n, default_init_t, const allocator_type &a)
+ : Base(n, a)
+ {
+ container_detail::insert_default_initialized_n_proxy<Allocator, iterator> proxy;
+ proxy.uninitialized_copy_n_and_update(this->alloc(), this->begin(), n);
+ //deque_base will deallocate in case of exception...
+ }
+
+ //! <b>Effects</b>: Constructs a deque that will use a copy of allocator a
//! and inserts n copies of value.
//!
//! <b>Throws</b>: If allocator_type's default constructor
@@ -605,8 +641,7 @@ class deque : protected deque_base<Allocator>
)
: Base(a)
{
- typedef typename std::iterator_traits<InIt>::iterator_category ItCat;
- this->priv_range_initialize(first, last, ItCat());
+ this->priv_range_initialize(first, last);
}
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
@@ -620,7 +655,7 @@ class deque : protected deque_base<Allocator>
deque(std::initializer_list<value_type> il, const allocator_type& a = allocator_type())
: Base(a)
{
- this->priv_range_initialize(il.begin(), il.end(), std::input_iterator_tag());
+ this->priv_range_initialize(il.begin(), il.end());
}
#endif
@@ -639,13 +674,13 @@ class deque : protected deque_base<Allocator>
}
}
- //! <b>Effects</b>: Move constructor. Moves mx's resources to *this.
+ //! <b>Effects</b>: Move constructor. Moves x's resources to *this.
//!
//! <b>Throws</b>: If allocator_type's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
deque(BOOST_RV_REF(deque) x)
- : Base(boost::move(static_cast<Base&>(x)))
+ : Base(BOOST_MOVE_BASE(Base, x))
{ this->swap_members(x); }
//! <b>Effects</b>: Copy constructs a vector using the specified allocator.
@@ -667,23 +702,24 @@ class deque : protected deque_base<Allocator>
}
//! <b>Effects</b>: Move constructor using the specified allocator.
- //! Moves mx's resources to *this if a == allocator_type().
+ //! Moves x's resources to *this if a == allocator_type().
//! Otherwise copies values from x to *this.
//!
//! <b>Throws</b>: If allocation or T's copy constructor throws.
//!
- //! <b>Complexity</b>: Constant if a == mx.get_allocator(), linear otherwise.
- deque(BOOST_RV_REF(deque) mx, const allocator_type &a)
+ //! <b>Complexity</b>: Constant if a == x.get_allocator(), linear otherwise.
+ deque(BOOST_RV_REF(deque) x, const allocator_type &a)
: Base(a)
{
- if(mx.alloc() == a){
- this->swap_members(mx);
+ if(x.alloc() == a){
+ this->swap_members(x);
}
else{
- if(mx.size()){
- this->priv_initialize_map(mx.size());
+ if(x.size()){
+ this->priv_initialize_map(x.size());
boost::container::uninitialized_copy_alloc
- (this->alloc(), mx.begin(), mx.end(), this->members_.m_start);
+ ( this->alloc(), boost::make_move_iterator(x.begin())
+ , boost::make_move_iterator(x.end()), this->members_.m_start);
}
}
}
@@ -694,7 +730,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the number of elements.
- ~deque() BOOST_CONTAINER_NOEXCEPT
+ ~deque() BOOST_NOEXCEPT_OR_NOTHROW
{
this->priv_destroy_range(this->members_.m_start, this->members_.m_finish);
}
@@ -734,7 +770,8 @@ class deque : protected deque_base<Allocator>
//! propagate_on_container_move_assignment is true or
//! this->get>allocator() == x.get_allocator(). Linear otherwise.
deque& operator= (BOOST_RV_REF(deque) x)
- BOOST_CONTAINER_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value)
+ BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_move_assignment::value
+ || allocator_traits_type::is_always_equal::value)
{
BOOST_ASSERT(this != &x);
allocator_type &this_alloc = this->alloc();
@@ -826,10 +863,10 @@ class deque : protected deque_base<Allocator>
>::type * = 0
)
{
- const size_type len = std::distance(first, last);
+ const size_type len = boost::container::iterator_distance(first, last);
if (len > size()) {
FwdIt mid = first;
- std::advance(mid, this->size());
+ boost::container::iterator_advance(mid, this->size());
boost::container::copy(first, mid, begin());
this->insert(this->cend(), mid, last);
}
@@ -855,7 +892,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: If allocator's copy constructor throws.
//!
//! <b>Complexity</b>: Constant.
- allocator_type get_allocator() const BOOST_CONTAINER_NOEXCEPT
+ allocator_type get_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
{ return Base::alloc(); }
//! <b>Effects</b>: Returns a reference to the internal allocator.
@@ -865,7 +902,7 @@ class deque : protected deque_base<Allocator>
//! <b>Complexity</b>: Constant.
//!
//! <b>Note</b>: Non-standard extension.
- const stored_allocator_type &get_stored_allocator() const BOOST_CONTAINER_NOEXCEPT
+ const stored_allocator_type &get_stored_allocator() const BOOST_NOEXCEPT_OR_NOTHROW
{ return Base::alloc(); }
//////////////////////////////////////////////
@@ -881,7 +918,7 @@ class deque : protected deque_base<Allocator>
//! <b>Complexity</b>: Constant.
//!
//! <b>Note</b>: Non-standard extension.
- stored_allocator_type &get_stored_allocator() BOOST_CONTAINER_NOEXCEPT
+ stored_allocator_type &get_stored_allocator() BOOST_NOEXCEPT_OR_NOTHROW
{ return Base::alloc(); }
//! <b>Effects</b>: Returns an iterator to the first element contained in the deque.
@@ -889,7 +926,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- iterator begin() BOOST_CONTAINER_NOEXCEPT
+ iterator begin() BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_start; }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the deque.
@@ -897,7 +934,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_iterator begin() const BOOST_CONTAINER_NOEXCEPT
+ const_iterator begin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_start; }
//! <b>Effects</b>: Returns an iterator to the end of the deque.
@@ -905,7 +942,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- iterator end() BOOST_CONTAINER_NOEXCEPT
+ iterator end() BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_finish; }
//! <b>Effects</b>: Returns a const_iterator to the end of the deque.
@@ -913,7 +950,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_iterator end() const BOOST_CONTAINER_NOEXCEPT
+ const_iterator end() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_finish; }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the beginning
@@ -922,7 +959,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- reverse_iterator rbegin() BOOST_CONTAINER_NOEXCEPT
+ reverse_iterator rbegin() BOOST_NOEXCEPT_OR_NOTHROW
{ return reverse_iterator(this->members_.m_finish); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
@@ -931,7 +968,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rbegin() const BOOST_CONTAINER_NOEXCEPT
+ const_reverse_iterator rbegin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return const_reverse_iterator(this->members_.m_finish); }
//! <b>Effects</b>: Returns a reverse_iterator pointing to the end
@@ -940,7 +977,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- reverse_iterator rend() BOOST_CONTAINER_NOEXCEPT
+ reverse_iterator rend() BOOST_NOEXCEPT_OR_NOTHROW
{ return reverse_iterator(this->members_.m_start); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
@@ -949,7 +986,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator rend() const BOOST_CONTAINER_NOEXCEPT
+ const_reverse_iterator rend() const BOOST_NOEXCEPT_OR_NOTHROW
{ return const_reverse_iterator(this->members_.m_start); }
//! <b>Effects</b>: Returns a const_iterator to the first element contained in the deque.
@@ -957,7 +994,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_iterator cbegin() const BOOST_CONTAINER_NOEXCEPT
+ const_iterator cbegin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_start; }
//! <b>Effects</b>: Returns a const_iterator to the end of the deque.
@@ -965,7 +1002,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_iterator cend() const BOOST_CONTAINER_NOEXCEPT
+ const_iterator cend() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_finish; }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the beginning
@@ -974,7 +1011,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crbegin() const BOOST_CONTAINER_NOEXCEPT
+ const_reverse_iterator crbegin() const BOOST_NOEXCEPT_OR_NOTHROW
{ return const_reverse_iterator(this->members_.m_finish); }
//! <b>Effects</b>: Returns a const_reverse_iterator pointing to the end
@@ -983,7 +1020,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_reverse_iterator crend() const BOOST_CONTAINER_NOEXCEPT
+ const_reverse_iterator crend() const BOOST_NOEXCEPT_OR_NOTHROW
{ return const_reverse_iterator(this->members_.m_start); }
//////////////////////////////////////////////
@@ -997,7 +1034,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- bool empty() const BOOST_CONTAINER_NOEXCEPT
+ bool empty() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_finish == this->members_.m_start; }
//! <b>Effects</b>: Returns the number of the elements contained in the deque.
@@ -1005,7 +1042,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- size_type size() const BOOST_CONTAINER_NOEXCEPT
+ size_type size() const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_finish - this->members_.m_start; }
//! <b>Effects</b>: Returns the largest possible size of the deque.
@@ -1013,7 +1050,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- size_type max_size() const BOOST_CONTAINER_NOEXCEPT
+ size_type max_size() const BOOST_NOEXCEPT_OR_NOTHROW
{ return allocator_traits_type::max_size(this->alloc()); }
//! <b>Effects</b>: Inserts or erases elements at the end such that
@@ -1100,7 +1137,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- reference front() BOOST_CONTAINER_NOEXCEPT
+ reference front() BOOST_NOEXCEPT_OR_NOTHROW
{ return *this->members_.m_start; }
//! <b>Requires</b>: !empty()
@@ -1111,7 +1148,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_reference front() const BOOST_CONTAINER_NOEXCEPT
+ const_reference front() const BOOST_NOEXCEPT_OR_NOTHROW
{ return *this->members_.m_start; }
//! <b>Requires</b>: !empty()
@@ -1122,7 +1159,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- reference back() BOOST_CONTAINER_NOEXCEPT
+ reference back() BOOST_NOEXCEPT_OR_NOTHROW
{ return *(end()-1); }
//! <b>Requires</b>: !empty()
@@ -1133,7 +1170,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_reference back() const BOOST_CONTAINER_NOEXCEPT
+ const_reference back() const BOOST_NOEXCEPT_OR_NOTHROW
{ return *(cend()-1); }
//! <b>Requires</b>: size() > n.
@@ -1144,7 +1181,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- reference operator[](size_type n) BOOST_CONTAINER_NOEXCEPT
+ reference operator[](size_type n) BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_start[difference_type(n)]; }
//! <b>Requires</b>: size() > n.
@@ -1155,9 +1192,70 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant.
- const_reference operator[](size_type n) const BOOST_CONTAINER_NOEXCEPT
+ const_reference operator[](size_type n) const BOOST_NOEXCEPT_OR_NOTHROW
{ return this->members_.m_start[difference_type(n)]; }
+ //! <b>Requires</b>: size() >= n.
+ //!
+ //! <b>Effects</b>: Returns an iterator to the nth element
+ //! from the beginning of the container. Returns end()
+ //! if n == size().
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Non-standard extension
+ iterator nth(size_type n) BOOST_NOEXCEPT_OR_NOTHROW
+ {
+ BOOST_ASSERT(this->size() >= n);
+ return iterator(this->begin()+n);
+ }
+
+ //! <b>Requires</b>: size() >= n.
+ //!
+ //! <b>Effects</b>: Returns a const_iterator to the nth element
+ //! from the beginning of the container. Returns end()
+ //! if n == size().
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Non-standard extension
+ const_iterator nth(size_type n) const BOOST_NOEXCEPT_OR_NOTHROW
+ {
+ BOOST_ASSERT(this->size() >= n);
+ return const_iterator(this->cbegin()+n);
+ }
+
+ //! <b>Requires</b>: size() >= n.
+ //!
+ //! <b>Effects</b>: Returns an iterator to the nth element
+ //! from the beginning of the container. Returns end()
+ //! if n == size().
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Non-standard extension
+ size_type index_of(iterator p) BOOST_NOEXCEPT_OR_NOTHROW
+ { return this->priv_index_of(p); }
+
+ //! <b>Requires</b>: begin() <= p <= end().
+ //!
+ //! <b>Effects</b>: Returns the index of the element pointed by p
+ //! and size() if p == end().
+ //!
+ //! <b>Throws</b>: Nothing.
+ //!
+ //! <b>Complexity</b>: Constant.
+ //!
+ //! <b>Note</b>: Non-standard extension
+ size_type index_of(const_iterator p) const BOOST_NOEXCEPT_OR_NOTHROW
+ { return this->priv_index_of(p); }
+
//! <b>Requires</b>: size() > n.
//!
//! <b>Effects</b>: Returns a reference to the nth element
@@ -1186,7 +1284,7 @@ class deque : protected deque_base<Allocator>
//
//////////////////////////////////////////////
- #if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
+ #if !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts an object of type T constructed with
//! std::forward<Args>(args)... in the beginning of the deque.
@@ -1195,7 +1293,7 @@ class deque : protected deque_base<Allocator>
//!
//! <b>Complexity</b>: Amortized constant time
template <class... Args>
- void emplace_front(Args&&... args)
+ void emplace_front(BOOST_FWD_REF(Args)... args)
{
if(this->priv_push_front_simple_available()){
allocator_traits_type::construct
@@ -1205,7 +1303,7 @@ class deque : protected deque_base<Allocator>
this->priv_push_front_simple_commit();
}
else{
- typedef container_detail::insert_non_movable_emplace_proxy<Allocator, iterator, Args...> type;
+ typedef container_detail::insert_nonmovable_emplace_proxy<Allocator, iterator, Args...> type;
this->priv_insert_front_aux_impl(1, type(boost::forward<Args>(args)...));
}
}
@@ -1217,7 +1315,7 @@ class deque : protected deque_base<Allocator>
//!
//! <b>Complexity</b>: Amortized constant time
template <class... Args>
- void emplace_back(Args&&... args)
+ void emplace_back(BOOST_FWD_REF(Args)... args)
{
if(this->priv_push_back_simple_available()){
allocator_traits_type::construct
@@ -1227,7 +1325,7 @@ class deque : protected deque_base<Allocator>
this->priv_push_back_simple_commit();
}
else{
- typedef container_detail::insert_non_movable_emplace_proxy<Allocator, iterator, Args...> type;
+ typedef container_detail::insert_nonmovable_emplace_proxy<Allocator, iterator, Args...> type;
this->priv_insert_back_aux_impl(1, type(boost::forward<Args>(args)...));
}
}
@@ -1242,7 +1340,7 @@ class deque : protected deque_base<Allocator>
//! <b>Complexity</b>: If p is end(), amortized constant time
//! Linear time otherwise.
template <class... Args>
- iterator emplace(const_iterator p, Args&&... args)
+ iterator emplace(const_iterator p, BOOST_FWD_REF(Args)... args)
{
if(p == this->cbegin()){
this->emplace_front(boost::forward<Args>(args)...);
@@ -1258,70 +1356,61 @@ class deque : protected deque_base<Allocator>
}
}
- #else //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
-
- //advanced_insert_int.hpp includes all necessary preprocessor machinery...
- #define BOOST_PP_LOCAL_MACRO(n) \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, > ) \
- void emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- if(priv_push_front_simple_available()){ \
- allocator_traits_type::construct \
- ( this->alloc() \
- , this->priv_push_front_simple_pos() \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- priv_push_front_simple_commit(); \
- } \
- else{ \
- typedef container_detail::BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, n) \
- <Allocator, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> type; \
- priv_insert_front_aux_impl \
- (1, type(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \
- } \
- } \
- \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- void emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- if(priv_push_back_simple_available()){ \
- allocator_traits_type::construct \
- ( this->alloc() \
- , this->priv_push_back_simple_pos() \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- priv_push_back_simple_commit(); \
- } \
- else{ \
- typedef container_detail::BOOST_PP_CAT(insert_non_movable_emplace_proxy_arg, n) \
- <Allocator, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> type; \
- priv_insert_back_aux_impl \
- (1, type(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \
- } \
- } \
- \
- BOOST_PP_EXPR_IF(n, template<) BOOST_PP_ENUM_PARAMS(n, class P) BOOST_PP_EXPR_IF(n, >) \
- iterator emplace(const_iterator p \
- BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_LIST, _)) \
- { \
- if(p == this->cbegin()){ \
- this->emplace_front(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- return this->begin(); \
- } \
- else if(p == cend()){ \
- this->emplace_back(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
- return (this->end()-1); \
- } \
- else{ \
- typedef container_detail::BOOST_PP_CAT(insert_emplace_proxy_arg, n) \
- <Allocator, iterator BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> type; \
- return this->priv_insert_aux_impl \
- (p, 1, type(BOOST_PP_ENUM(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _))); \
- } \
- } \
- //!
- #define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
- #include BOOST_PP_LOCAL_ITERATE()
-
- #endif //#ifdef BOOST_CONTAINER_PERFECT_FORWARDING
+ #else //!defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
+
+ #define BOOST_CONTAINER_DEQUE_EMPLACE_CODE(N) \
+ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\
+ void emplace_front(BOOST_MOVE_UREF##N)\
+ {\
+ if(priv_push_front_simple_available()){\
+ allocator_traits_type::construct\
+ ( this->alloc(), this->priv_push_front_simple_pos() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
+ priv_push_front_simple_commit();\
+ }\
+ else{\
+ typedef container_detail::insert_nonmovable_emplace_proxy##N\
+ <Allocator, iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\
+ priv_insert_front_aux_impl(1, type(BOOST_MOVE_FWD##N));\
+ }\
+ }\
+ \
+ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\
+ void emplace_back(BOOST_MOVE_UREF##N)\
+ {\
+ if(priv_push_back_simple_available()){\
+ allocator_traits_type::construct\
+ ( this->alloc(), this->priv_push_back_simple_pos() BOOST_MOVE_I##N BOOST_MOVE_FWD##N);\
+ priv_push_back_simple_commit();\
+ }\
+ else{\
+ typedef container_detail::insert_nonmovable_emplace_proxy##N\
+ <Allocator, iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\
+ priv_insert_back_aux_impl(1, type(BOOST_MOVE_FWD##N));\
+ }\
+ }\
+ \
+ BOOST_MOVE_TMPL_LT##N BOOST_MOVE_CLASS##N BOOST_MOVE_GT##N\
+ iterator emplace(const_iterator p BOOST_MOVE_I##N BOOST_MOVE_UREF##N)\
+ {\
+ if(p == this->cbegin()){\
+ this->emplace_front(BOOST_MOVE_FWD##N);\
+ return this->begin();\
+ }\
+ else if(p == cend()){\
+ this->emplace_back(BOOST_MOVE_FWD##N);\
+ return (--this->end());\
+ }\
+ else{\
+ typedef container_detail::insert_emplace_proxy_arg##N\
+ <Allocator, iterator BOOST_MOVE_I##N BOOST_MOVE_TARG##N> type;\
+ return this->priv_insert_aux_impl(p, 1, type(BOOST_MOVE_FWD##N));\
+ }\
+ }
+ //
+ BOOST_MOVE_ITERATE_0TO9(BOOST_CONTAINER_DEQUE_EMPLACE_CODE)
+ #undef BOOST_CONTAINER_DEQUE_EMPLACE_CODE
+
+ #endif // !defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES)
#if defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
//! <b>Effects</b>: Inserts a copy of x at the front of the deque.
@@ -1333,7 +1422,7 @@ class deque : protected deque_base<Allocator>
void push_front(const T &x);
//! <b>Effects</b>: Constructs a new element in the front of the deque
- //! and moves the resources of mx to this new element.
+ //! and moves the resources of x to this new element.
//!
//! <b>Throws</b>: If memory allocation throws.
//!
@@ -1353,7 +1442,7 @@ class deque : protected deque_base<Allocator>
void push_back(const T &x);
//! <b>Effects</b>: Constructs a new element in the end of the deque
- //! and moves the resources of mx to this new element.
+ //! and moves the resources of x to this new element.
//!
//! <b>Throws</b>: If memory allocation throws.
//!
@@ -1379,7 +1468,7 @@ class deque : protected deque_base<Allocator>
//! <b>Requires</b>: p must be a valid iterator of *this.
//!
- //! <b>Effects</b>: Insert a new element before p with mx's resources.
+ //! <b>Effects</b>: Insert a new element before p with x's resources.
//!
//! <b>Returns</b>: an iterator to the inserted element.
//!
@@ -1416,7 +1505,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced InIt throws or T's copy constructor throws.
//!
- //! <b>Complexity</b>: Linear to std::distance [first, last).
+ //! <b>Complexity</b>: Linear to distance [first, last).
template <class InIt>
iterator insert(const_iterator pos, InIt first, InIt last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1447,7 +1536,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced std::initializer_list throws or T's copy constructor throws.
//!
- //! <b>Complexity</b>: Linear to std::distance [il.begin(), il.end()).
+ //! <b>Complexity</b>: Linear to distance [il.begin(), il.end()).
iterator insert(const_iterator pos, std::initializer_list<value_type> il)
{ return insert(pos, il.begin(), il.end()); }
#endif
@@ -1464,7 +1553,7 @@ class deque : protected deque_base<Allocator>
)
{
container_detail::insert_range_proxy<Allocator, FwdIt, iterator> proxy(first);
- return priv_insert_aux_impl(p, (size_type)std::distance(first, last), proxy);
+ return priv_insert_aux_impl(p, boost::container::iterator_distance(first, last), proxy);
}
#endif
@@ -1473,7 +1562,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant time.
- void pop_front() BOOST_CONTAINER_NOEXCEPT
+ void pop_front() BOOST_NOEXCEPT_OR_NOTHROW
{
if (this->members_.m_start.m_cur != this->members_.m_start.m_last - 1) {
allocator_traits_type::destroy
@@ -1491,7 +1580,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Constant time.
- void pop_back() BOOST_CONTAINER_NOEXCEPT
+ void pop_back() BOOST_NOEXCEPT_OR_NOTHROW
{
if (this->members_.m_finish.m_cur != this->members_.m_finish.m_first) {
--this->members_.m_finish.m_cur;
@@ -1512,17 +1601,17 @@ class deque : protected deque_base<Allocator>
//! last element (if pos is near the end) or the first element
//! if(pos is near the beginning).
//! Constant if pos is the first or the last element.
- iterator erase(const_iterator pos) BOOST_CONTAINER_NOEXCEPT
+ iterator erase(const_iterator pos) BOOST_NOEXCEPT_OR_NOTHROW
{
iterator next = pos.unconst();
++next;
size_type index = pos - this->members_.m_start;
if (index < (this->size()/2)) {
- boost::move_backward(this->begin(), pos.unconst(), next);
+ boost::container::move_backward(this->begin(), pos.unconst(), next);
pop_front();
}
else {
- boost::move(next, this->end(), pos.unconst());
+ boost::container::move(next, this->end(), pos.unconst());
pop_back();
}
return this->members_.m_start + index;
@@ -1536,7 +1625,7 @@ class deque : protected deque_base<Allocator>
//! last plus the elements between pos and the
//! last element (if pos is near the end) or the first element
//! if(pos is near the beginning).
- iterator erase(const_iterator first, const_iterator last) BOOST_CONTAINER_NOEXCEPT
+ iterator erase(const_iterator first, const_iterator last) BOOST_NOEXCEPT_OR_NOTHROW
{
if (first == this->members_.m_start && last == this->members_.m_finish) {
this->clear();
@@ -1546,7 +1635,7 @@ class deque : protected deque_base<Allocator>
const size_type n = static_cast<size_type>(last - first);
const size_type elems_before = static_cast<size_type>(first - this->members_.m_start);
if (elems_before < (this->size() - n) - elems_before) {
- boost::move_backward(begin(), first.unconst(), last.unconst());
+ boost::container::move_backward(begin(), first.unconst(), last.unconst());
iterator new_start = this->members_.m_start + n;
if(!Base::traits_t::trivial_dctr_after_move)
this->priv_destroy_range(this->members_.m_start, new_start);
@@ -1554,7 +1643,7 @@ class deque : protected deque_base<Allocator>
this->members_.m_start = new_start;
}
else {
- boost::move(last.unconst(), end(), first.unconst());
+ boost::container::move(last.unconst(), end(), first.unconst());
iterator new_finish = this->members_.m_finish - n;
if(!Base::traits_t::trivial_dctr_after_move)
this->priv_destroy_range(new_finish, this->members_.m_finish);
@@ -1571,6 +1660,8 @@ class deque : protected deque_base<Allocator>
//!
//! <b>Complexity</b>: Constant.
void swap(deque &x)
+ BOOST_NOEXCEPT_IF(allocator_traits_type::propagate_on_container_swap::value
+ || allocator_traits_type::is_always_equal::value)
{
this->swap_members(x);
container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag;
@@ -1583,7 +1674,7 @@ class deque : protected deque_base<Allocator>
//! <b>Throws</b>: Nothing.
//!
//! <b>Complexity</b>: Linear to the number of elements in the deque.
- void clear() BOOST_CONTAINER_NOEXCEPT
+ void clear() BOOST_NOEXCEPT_OR_NOTHROW
{
for (index_pointer node = this->members_.m_start.m_node + 1;
node < this->members_.m_finish.m_node;
@@ -1607,7 +1698,7 @@ class deque : protected deque_base<Allocator>
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const deque& x, const deque& y)
- { return x.size() == y.size() && std::equal(x.begin(), x.end(), y.begin()); }
+ { return x.size() == y.size() && ::boost::container::algo_equal(x.begin(), x.end(), y.begin()); }
//! <b>Effects</b>: Returns true if x and y are unequal
//!
@@ -1619,7 +1710,7 @@ class deque : protected deque_base<Allocator>
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const deque& x, const deque& y)
- { return std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
+ { return ::boost::container::algo_lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()); }
//! <b>Effects</b>: Returns true if x is greater than y
//!
@@ -1648,6 +1739,13 @@ class deque : protected deque_base<Allocator>
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
private:
+ size_type priv_index_of(const_iterator p) const
+ {
+ BOOST_ASSERT(this->cbegin() <= p);
+ BOOST_ASSERT(p <= this->cend());
+ return static_cast<size_type>(p - this->cbegin());
+ }
+
void priv_erase_last_n(size_type n)
{
if(n == this->size()) {
@@ -1743,21 +1841,19 @@ class deque : protected deque_base<Allocator>
void priv_destroy_range(iterator p, iterator p2)
{
- for(;p != p2; ++p){
- allocator_traits_type::destroy
- ( this->alloc()
- , container_detail::to_raw_pointer(container_detail::iterator_to_pointer(p))
- );
+ if(!Base::traits_t::trivial_dctr){
+ for(;p != p2; ++p){
+ allocator_traits_type::destroy(this->alloc(), container_detail::iterator_to_raw_pointer(p));
+ }
}
}
void priv_destroy_range(pointer p, pointer p2)
{
- for(;p != p2; ++p){
- allocator_traits_type::destroy
- ( this->alloc()
- , container_detail::to_raw_pointer(container_detail::iterator_to_pointer(p))
- );
+ if(!Base::traits_t::trivial_dctr){
+ for(;p != p2; ++p){
+ allocator_traits_type::destroy(this->alloc(), container_detail::iterator_to_raw_pointer(p));
+ }
}
}
@@ -1787,7 +1883,7 @@ class deque : protected deque_base<Allocator>
::boost::container::uninitialized_move_alloc
(this->alloc(), this->members_.m_start, start_n, new_start);
this->members_.m_start = new_start;
- boost::move(start_n, pos, old_start);
+ boost::container::move(start_n, pos, old_start);
proxy.copy_n_and_update(this->alloc(), pos - n, n);
}
else {
@@ -1817,7 +1913,7 @@ class deque : protected deque_base<Allocator>
::boost::container::uninitialized_move_alloc
(this->alloc(), finish_n, old_finish, old_finish);
this->members_.m_finish = new_finish;
- boost::move_backward(pos, finish_n, old_finish);
+ boost::container::move_backward(pos, finish_n, old_finish);
proxy.copy_n_and_update(this->alloc(), pos, n);
}
else {
@@ -1877,9 +1973,9 @@ class deque : protected deque_base<Allocator>
// but none of the deque's elements have yet been constructed.
void priv_fill_initialize(const value_type& value)
{
- index_pointer cur;
+ index_pointer cur = this->members_.m_start.m_node;
BOOST_TRY {
- for (cur = this->members_.m_start.m_node; cur < this->members_.m_finish.m_node; ++cur){
+ for ( ; cur < this->members_.m_finish.m_node; ++cur){
boost::container::uninitialized_fill_alloc
(this->alloc(), *cur, *cur + this->s_buffer_size(), value);
}
@@ -1894,7 +1990,8 @@ class deque : protected deque_base<Allocator>
}
template <class InIt>
- void priv_range_initialize(InIt first, InIt last, std::input_iterator_tag)
+ typename iterator_enable_if_tag<InIt, std::input_iterator_tag>::type
+ priv_range_initialize(InIt first, InIt last)
{
this->priv_initialize_map(0);
BOOST_TRY {
@@ -1909,19 +2006,18 @@ class deque : protected deque_base<Allocator>
}
template <class FwdIt>
- void priv_range_initialize(FwdIt first, FwdIt last, std::forward_iterator_tag)
+ typename iterator_disable_if_tag<FwdIt, std::input_iterator_tag>::type
+ priv_range_initialize(FwdIt first, FwdIt last)
{
size_type n = 0;
- n = std::distance(first, last);
+ n = boost::container::iterator_distance(first, last);
this->priv_initialize_map(n);
- index_pointer cur_node;
+ index_pointer cur_node = this->members_.m_start.m_node;
BOOST_TRY {
- for (cur_node = this->members_.m_start.m_node;
- cur_node < this->members_.m_finish.m_node;
- ++cur_node) {
+ for (; cur_node < this->members_.m_finish.m_node; ++cur_node) {
FwdIt mid = first;
- std::advance(mid, this->s_buffer_size());
+ boost::container::iterator_advance(mid, this->s_buffer_size());
::boost::container::uninitialized_copy_alloc(this->alloc(), first, mid, *cur_node);
first = mid;
}
@@ -1935,7 +2031,7 @@ class deque : protected deque_base<Allocator>
}
// Called only if this->members_.m_finish.m_cur == this->members_.m_finish.m_first.
- void priv_pop_back_aux() BOOST_CONTAINER_NOEXCEPT
+ void priv_pop_back_aux() BOOST_NOEXCEPT_OR_NOTHROW
{
this->priv_deallocate_node(this->members_.m_finish.m_first);
this->members_.m_finish.priv_set_node(this->members_.m_finish.m_node - 1);
@@ -1950,7 +2046,7 @@ class deque : protected deque_base<Allocator>
// if the deque has at least one element (a precondition for this member
// function), and if this->members_.m_start.m_cur == this->members_.m_start.m_last, then the deque
// must have at least two nodes.
- void priv_pop_front_aux() BOOST_CONTAINER_NOEXCEPT
+ void priv_pop_front_aux() BOOST_NOEXCEPT_OR_NOTHROW
{
allocator_traits_type::destroy
( this->alloc()
@@ -1997,9 +2093,9 @@ class deque : protected deque_base<Allocator>
if (new_nodes + 1 > s){
this->priv_reallocate_map(new_nodes, false);
}
- size_type i;
+ size_type i = 1;
BOOST_TRY {
- for (i = 1; i <= new_nodes; ++i)
+ for (; i <= new_nodes; ++i)
*(this->members_.m_finish.m_node + i) = this->priv_allocate_node();
}
BOOST_CATCH(...) {
@@ -2022,9 +2118,9 @@ class deque : protected deque_base<Allocator>
new_nstart = this->members_.m_map + (this->members_.m_map_size - new_num_nodes) / 2
+ (add_at_front ? nodes_to_add : 0);
if (new_nstart < this->members_.m_start.m_node)
- boost::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart);
+ boost::container::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart);
else
- boost::move_backward
+ boost::container::move_backward
(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart + old_num_nodes);
}
else {
@@ -2034,7 +2130,7 @@ class deque : protected deque_base<Allocator>
index_pointer new_map = this->priv_allocate_map(new_map_size);
new_nstart = new_map + (new_map_size - new_num_nodes) / 2
+ (add_at_front ? nodes_to_add : 0);
- boost::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart);
+ boost::container::move(this->members_.m_start.m_node, this->members_.m_finish.m_node + 1, new_nstart);
this->priv_deallocate_map(this->members_.m_map, this->members_.m_map_size);
this->members_.m_map = new_map;
@@ -2057,8 +2153,11 @@ namespace boost {
//!specialization for optimizations
template <class T, class Allocator>
struct has_trivial_destructor_after_move<boost::container::deque<T, Allocator> >
- : public ::boost::has_trivial_destructor_after_move<Allocator>
-{};
+{
+ typedef typename ::boost::container::allocator_traits<Allocator>::pointer pointer;
+ static const bool value = ::boost::has_trivial_destructor_after_move<Allocator>::value &&
+ ::boost::has_trivial_destructor_after_move<pointer>::value;
+};
}