Refactored uses of <iterator> and <algorithm> to avoid dependencies where possible.

This commit is contained in:
Ion Gaztañaga
2014-11-26 07:08:06 +01:00
parent d514c1ab66
commit 7971dc6602
41 changed files with 585 additions and 454 deletions

View File

@@ -32,8 +32,7 @@
#include <boost/utility/addressof.hpp>
#include <boost/static_assert.hpp>
#include <boost/move/utility_core.hpp>
#include <memory>
#include <algorithm>
#include <utility>
#include <cstddef>

View File

@@ -24,11 +24,9 @@
#include <boost/container/allocator_traits.hpp>
#include <boost/container/container_fwd.hpp>
#include <boost/container/throw_exception.hpp>
#include <cstddef>
#include <iterator>
#include <boost/container/detail/iterator.hpp>
#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>
@@ -41,8 +39,12 @@
#include <boost/move/detail/move_helpers.hpp>
#include <boost/move/traits.hpp>
#include <boost/container/detail/advanced_insert_int.hpp>
#include <boost/container/detail/algorithm.hpp> //algo_equal(), algo_lexicographical_compare
#include <boost/core/no_exceptions_support.hpp>
#include <cstddef>
#include <memory> //std::allocator
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
@@ -353,10 +355,10 @@ class deque_base
void swap_members(deque_base &x) BOOST_CONTAINER_NOEXCEPT
{
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::container::swap_dispatch(this->members_.m_start, x.members_.m_start);
::boost::container::swap_dispatch(this->members_.m_finish, x.members_.m_finish);
::boost::container::swap_dispatch(this->members_.m_map, x.members_.m_map);
::boost::container::swap_dispatch(this->members_.m_map_size, x.members_.m_map_size);
}
void priv_initialize_map(size_type num_elements)
@@ -504,8 +506,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
@@ -604,7 +606,7 @@ class deque : protected deque_base<Allocator>
)
: Base(a)
{
typedef typename std::iterator_traits<InIt>::iterator_category ItCat;
typedef typename boost::container::iterator_traits<InIt>::iterator_category ItCat;
this->priv_range_initialize(first, last, ItCat());
}
@@ -825,10 +827,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);
}
@@ -1476,7 +1478,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)
@@ -1507,7 +1509,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
@@ -1524,7 +1526,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
@@ -1667,7 +1669,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
//!
@@ -1679,7 +1681,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
//!
@@ -1979,7 +1981,7 @@ class deque : protected deque_base<Allocator>
void priv_range_initialize(FwdIt first, FwdIt last, std::forward_iterator_tag)
{
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;
@@ -1988,7 +1990,7 @@ class deque : protected deque_base<Allocator>
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;
}

View File

@@ -25,8 +25,9 @@
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/utilities.hpp>
#include <boost/container/detail/type_traits.hpp>
#include <boost/container/detail/iterator.hpp>
#include <boost/container/detail/iterators.hpp>
#include <iterator> //std::iterator_traits
#include <boost/assert.hpp>
#include <boost/core/no_exceptions_support.hpp>
@@ -186,13 +187,13 @@ struct insert_move_proxy
};
template<class It, class A>
insert_move_proxy<A, It> get_insert_value_proxy(BOOST_RV_REF(typename std::iterator_traits<It>::value_type) v)
insert_move_proxy<A, It> get_insert_value_proxy(BOOST_RV_REF(typename boost::container::iterator_traits<It>::value_type) v)
{
return insert_move_proxy<A, It>(v);
}
template<class It, class A>
insert_copy_proxy<A, It> get_insert_value_proxy(const typename std::iterator_traits<It>::value_type &v)
insert_copy_proxy<A, It> get_insert_value_proxy(const typename boost::container::iterator_traits<It>::value_type &v)
{
return insert_copy_proxy<A, It>(v);
}

View File

@@ -0,0 +1,60 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2014-2014.
//
// 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)
//
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_CONTAINER_DETAIL_ALGORITHM_HPP
#define BOOST_CONTAINER_DETAIL_ALGORITHM_HPP
#if defined(_MSC_VER)
# pragma once
#endif
namespace boost {
namespace container {
template<class InputIt1, class InputIt2>
bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2)
{
for (; first1 != last1; ++first1, ++first2) {
if (!(*first1 == *first2)) {
return false;
}
}
return true;
}
template<class InputIt1, class InputIt2, class BinaryPredicate>
bool algo_equal(InputIt1 first1, InputIt1 last1, InputIt2 first2, BinaryPredicate p)
{
for (; first1 != last1; ++first1, ++first2) {
if (!p(*first1, *first2)) {
return false;
}
}
return true;
}
template <class InputIterator1, class InputIterator2>
bool algo_lexicographical_compare (InputIterator1 first1, InputIterator1 last1,
InputIterator2 first2, InputIterator2 last2)
{
while (first1 != last1){
if (first2 == last2 || *first2 < *first1) return false;
else if (*first1 < *first2) return true;
++first1; ++first2;
}
return (first2 != last2);
}
} //namespace container {
} //namespace boost {
#endif //#ifndef BOOST_CONTAINER_DETAIL_ALGORITHM_HPP

View File

@@ -1,6 +1,6 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2005-2013.
// (C) Copyright Ion Gaztanaga 2014-2014.
//
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
@@ -10,15 +10,13 @@
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP
#define BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP
#ifndef BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP
#define BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP
#if defined(_MSC_VER)
# pragma once
#endif
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/detail/workaround.hpp>
#include <boost/container/allocator_traits.hpp>
#include <boost/container/detail/iterators.hpp>
@@ -56,7 +54,5 @@ inline void construct_in_place(A &a, T *dest, emplace_iterator<U, EF, D> ei)
} //namespace container {
} //namespace boost {
#include <boost/container/detail/config_end.hpp>
#endif //#ifndef BOOST_CONTAINER_DETAIL_ALGORITHMS_HPP
#endif //#ifndef BOOST_CONTAINER_DETAIL_CONSTRUCT_IN_PLACE_HPP

View File

@@ -20,10 +20,6 @@
#include <boost/container/container_fwd.hpp>
#include <algorithm>
#include <functional>
#include <utility>
#include <boost/type_traits/has_trivial_destructor.hpp>
#include <boost/move/utility_core.hpp>
@@ -32,6 +28,8 @@
#include <boost/container/vector.hpp>
#include <boost/container/detail/value_init.hpp>
#include <boost/container/detail/destroyers.hpp>
#include <boost/container/detail/algorithm.hpp> //algo_equal(), algo_lexicographical_compare
#include <boost/container/detail/iterator.hpp>
#include <boost/container/allocator_traits.hpp>
#ifdef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
#include <boost/intrusive/pointer_traits.hpp>
@@ -39,10 +37,10 @@
#include <boost/aligned_storage.hpp>
#include <boost/move/make_unique.hpp>
#include <utility> //std::pair
namespace boost {
namespace container {
namespace container_detail {
template<class Compare, class Value, class KeyOfValue>
@@ -78,22 +76,20 @@ template<class Pointer>
struct get_flat_tree_iterators
{
#ifdef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
typedef Pointer iterator;
typedef Pointer iterator;
typedef typename boost::intrusive::
pointer_traits<Pointer>::element_type iterator_element_type;
pointer_traits<Pointer>::element_type iterator_element_type;
typedef typename boost::intrusive::
pointer_traits<Pointer>:: template
rebind_pointer<const iterator_element_type>::type const_iterator;
rebind_pointer<const iterator_element_type>::type const_iterator;
#else //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
typedef typename boost::container::container_detail::
vec_iterator<Pointer, false> iterator;
vec_iterator<Pointer, false> iterator;
typedef typename boost::container::container_detail::
vec_iterator<Pointer, true > const_iterator;
vec_iterator<Pointer, true > const_iterator;
#endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
typedef boost::container::container_detail::
reverse_iterator<iterator> reverse_iterator;
typedef boost::container::container_detail::
reverse_iterator<const_iterator> const_reverse_iterator;
typedef boost::container::reverse_iterator<iterator> reverse_iterator;
typedef boost::container::reverse_iterator<const_iterator> const_reverse_iterator;
};
template <class Key, class Value, class KeyOfValue,
@@ -428,7 +424,7 @@ class flat_tree
#endif
)
{
const size_type len = static_cast<size_type>(std::distance(first, last));
const size_type len = static_cast<size_type>(boost::container::iterator_distance(first, last));
this->reserve(this->size()+len);
this->priv_insert_equal_loop(first, last);
}
@@ -455,7 +451,7 @@ class flat_tree
#endif
)
{
const size_type len = static_cast<size_type>(std::distance(first, last));
const size_type len = static_cast<size_type>(boost::container::iterator_distance(first, last));
this->reserve(this->size()+len);
this->priv_insert_equal_loop_ordered(first, last);
}
@@ -706,13 +702,12 @@ class flat_tree
friend bool operator==(const flat_tree& x, const flat_tree& 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());
}
friend bool operator<(const flat_tree& x, const flat_tree& 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());
}
friend bool operator!=(const flat_tree& x, const flat_tree& y)
@@ -948,7 +943,7 @@ class flat_tree
template <class BidirIt>
void priv_insert_ordered_range(const bool unique_values, BidirIt first, BidirIt last)
{
size_type len = static_cast<size_type>(std::distance(first, last));
size_type len = static_cast<size_type>(boost::container::iterator_distance(first, last));
//Prereserve all memory so that iterators are not invalidated
this->reserve(this->size()+len);
//Auxiliary data for insertion positions.
@@ -967,10 +962,10 @@ class flat_tree
size_type unique_burst = 0u;
size_type checked = 0;
for(; checked != burst; ++checked){
//Get the insertion position for each key, use std::iterator_traits<BidirIt>::value_type
//Get the insertion position for each key, use iterator_traits<BidirIt>::value_type
//because it can be different from container::value_type
//(e.g. conversion between std::pair<A, B> -> boost::container::pair<A, B>
const typename std::iterator_traits<BidirIt>::value_type & val = *first;
const typename boost::container::iterator_traits<BidirIt>::value_type & val = *first;
pos = const_cast<const flat_tree&>(*this).priv_lower_bound(pos, ce, KeyOfValue()(val));
//Check if already present
if (pos != ce){
@@ -1006,7 +1001,7 @@ class flat_tree
BOOST_ASSERT(first == last);
}
else{
BOOST_ASSERT(size_type(std::distance(first, last)) == len);
BOOST_ASSERT(size_type(boost::container::iterator_distance(first, last)) == len);
if(len)
this->m_data.m_vect.insert(this->m_data.m_vect.cend(), len, first, last);
}

View File

@@ -0,0 +1,33 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright Ion Gaztanaga 2014-2014.
//
// 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)
//
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_CONTAINER_DETAIL_ITERATOR_HPP
#define BOOST_CONTAINER_DETAIL_ITERATOR_HPP
#if defined(_MSC_VER)
# pragma once
#endif
#include <boost/intrusive/detail/iterator.hpp>
namespace boost {
namespace container {
using ::boost::intrusive::iterator_traits;
using ::boost::intrusive::iterator_distance;
using ::boost::intrusive::iterator_advance;
using ::boost::intrusive::iterator;
} //namespace container {
} //namespace boost {
#endif //#ifndef BOOST_CONTAINER_DETAIL_ITERATORS_HPP

View File

@@ -32,14 +32,14 @@
#include <boost/container/detail/preprocessor.hpp>
#endif
#include <iterator>
#include <boost/container/detail/iterator.hpp>
namespace boost {
namespace container {
template <class T, class Difference = std::ptrdiff_t>
class constant_iterator
: public std::iterator
: public ::boost::container::iterator
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
{
typedef constant_iterator<T, Difference> this_type;
@@ -150,7 +150,7 @@ class constant_iterator
template <class T, class Difference>
class value_init_construct_iterator
: public std::iterator
: public ::boost::container::iterator
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
{
typedef value_init_construct_iterator<T, Difference> this_type;
@@ -261,7 +261,7 @@ class value_init_construct_iterator
template <class T, class Difference>
class default_init_construct_iterator
: public std::iterator
: public ::boost::container::iterator
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
{
typedef default_init_construct_iterator<T, Difference> this_type;
@@ -373,7 +373,7 @@ class default_init_construct_iterator
template <class T, class Difference = std::ptrdiff_t>
class repeat_iterator
: public std::iterator
: public ::boost::container::iterator
<std::random_access_iterator_tag, T, Difference>
{
typedef repeat_iterator<T, Difference> this_type;
@@ -483,7 +483,7 @@ class repeat_iterator
template <class T, class EmplaceFunctor, class Difference /*= std::ptrdiff_t*/>
class emplace_iterator
: public std::iterator
: public ::boost::container::iterator
<std::random_access_iterator_tag, T, Difference, const T*, const T &>
{
typedef emplace_iterator this_type;
@@ -709,8 +709,8 @@ struct iiterator_types
{
typedef typename IIterator::value_type it_value_type;
typedef typename iiterator_node_value_type<it_value_type>::type value_type;
typedef typename std::iterator_traits<IIterator>::pointer it_pointer;
typedef typename std::iterator_traits<IIterator>::difference_type difference_type;
typedef typename boost::container::iterator_traits<IIterator>::pointer it_pointer;
typedef typename boost::container::iterator_traits<IIterator>::difference_type difference_type;
typedef typename ::boost::intrusive::pointer_traits<it_pointer>::
template rebind_pointer<value_type>::type pointer;
typedef typename ::boost::intrusive::pointer_traits<it_pointer>::
@@ -723,9 +723,9 @@ struct iiterator_types
};
template<class IIterator, bool IsConst>
struct std_iterator
struct iterator_types
{
typedef typename std::iterator
typedef typename ::boost::container::iterator
< typename iiterator_types<IIterator>::iterator_category
, typename iiterator_types<IIterator>::value_type
, typename iiterator_types<IIterator>::difference_type
@@ -734,9 +734,9 @@ struct std_iterator
};
template<class IIterator>
struct std_iterator<IIterator, false>
struct iterator_types<IIterator, false>
{
typedef typename std::iterator
typedef typename ::boost::container::iterator
< typename iiterator_types<IIterator>::iterator_category
, typename iiterator_types<IIterator>::value_type
, typename iiterator_types<IIterator>::difference_type
@@ -745,9 +745,9 @@ struct std_iterator<IIterator, false>
};
template<class IIterator, bool IsConst>
class iterator
class iterator_from_iiterator
{
typedef typename std_iterator<IIterator, IsConst>::type types_t;
typedef typename iterator_types<IIterator, IsConst>::type types_t;
public:
typedef typename types_t::pointer pointer;
@@ -756,45 +756,45 @@ class iterator
typedef typename types_t::iterator_category iterator_category;
typedef typename types_t::value_type value_type;
iterator()
iterator_from_iiterator()
{}
explicit iterator(IIterator iit) BOOST_CONTAINER_NOEXCEPT
explicit iterator_from_iiterator(IIterator iit) BOOST_CONTAINER_NOEXCEPT
: m_iit(iit)
{}
iterator(iterator<IIterator, false> const& other) BOOST_CONTAINER_NOEXCEPT
iterator_from_iiterator(iterator_from_iiterator<IIterator, false> const& other) BOOST_CONTAINER_NOEXCEPT
: m_iit(other.get())
{}
iterator& operator++() BOOST_CONTAINER_NOEXCEPT
iterator_from_iiterator& operator++() BOOST_CONTAINER_NOEXCEPT
{ ++this->m_iit; return *this; }
iterator operator++(int) BOOST_CONTAINER_NOEXCEPT
iterator_from_iiterator operator++(int) BOOST_CONTAINER_NOEXCEPT
{
iterator result (*this);
iterator_from_iiterator result (*this);
++this->m_iit;
return result;
}
iterator& operator--() BOOST_CONTAINER_NOEXCEPT
iterator_from_iiterator& operator--() BOOST_CONTAINER_NOEXCEPT
{
//If the iterator is not a bidirectional iterator, operator-- should not exist
BOOST_STATIC_ASSERT((is_bidirectional_iterator<iterator>::value));
//If the iterator_from_iiterator is not a bidirectional iterator, operator-- should not exist
BOOST_STATIC_ASSERT((is_bidirectional_iterator<iterator_from_iiterator>::value));
--this->m_iit; return *this;
}
iterator operator--(int) BOOST_CONTAINER_NOEXCEPT
iterator_from_iiterator operator--(int) BOOST_CONTAINER_NOEXCEPT
{
iterator result (*this);
iterator_from_iiterator result (*this);
--this->m_iit;
return result;
}
friend bool operator== (const iterator& l, const iterator& r) BOOST_CONTAINER_NOEXCEPT
friend bool operator== (const iterator_from_iiterator& l, const iterator_from_iiterator& r) BOOST_CONTAINER_NOEXCEPT
{ return l.m_iit == r.m_iit; }
friend bool operator!= (const iterator& l, const iterator& r) BOOST_CONTAINER_NOEXCEPT
friend bool operator!= (const iterator_from_iiterator& l, const iterator_from_iiterator& r) BOOST_CONTAINER_NOEXCEPT
{ return !(l == r); }
reference operator*() const BOOST_CONTAINER_NOEXCEPT
@@ -810,9 +810,10 @@ class iterator
IIterator m_iit;
};
using ::boost::intrusive::detail::reverse_iterator;
} //namespace container_detail {
using ::boost::intrusive::reverse_iterator;
} //namespace container {
} //namespace boost {

View File

@@ -39,7 +39,7 @@
#include <boost/container/detail/preprocessor.hpp>
#endif
#include <boost/container/detail/algorithms.hpp>
#include <boost/container/detail/construct_in_place.hpp>

View File

@@ -25,8 +25,6 @@
#include <boost/intrusive/slist.hpp>
#include <boost/move/utility_core.hpp>
#include <cstddef>
#include <functional> //std::unary_function
#include <algorithm> //std::swap
#include <cassert>
namespace boost {

View File

@@ -26,7 +26,7 @@
#include <boost/container/detail/type_traits.hpp>
#include <utility> //std::pair
#include <algorithm> //std::swap
#include <boost/container/detail/swap.hpp> //swap
#include <boost/move/utility_core.hpp>
@@ -272,9 +272,8 @@ struct pair
//swap
void swap(pair& p)
{
using std::swap;
swap(this->first, p.first);
swap(this->second, p.second);
::boost::container::adl_swap(this->first, p.first);
::boost::container::adl_swap(this->second, p.second);
}
};

View File

@@ -0,0 +1,77 @@
//////////////////////////////////////////////////////////////////////////////
//
// (C) Copyright 2007, 2008 Steven Watanabe, Joseph Gauterin, Niels Dekker
// (C) Copyright Ion Gaztanaga 2005-2013. 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)
//
// See http://www.boost.org/libs/container for documentation.
//
//////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_CONTAINER_DETAIL_SWAP_HPP
#define BOOST_CONTAINER_DETAIL_SWAP_HPP
#if defined(_MSC_VER)
# pragma once
#endif
//Based on Boost.Core's swap, but defaulting to a move-enabled swap.
//
// Note: the implementation of this utility contains various workarounds:
// - swap_impl is put outside the boost namespace, to avoid infinite
// recursion (causing stack overflow) when swapping objects of a primitive
// type.
// - swap_impl has a using-directive, rather than a using-declaration,
// because some compilers (including MSVC 7.1, Borland 5.9.3, and
// Intel 8.1) don't do argument-dependent lookup when it has a
// using-declaration instead.
// - boost::swap has two template arguments, instead of one, to
// avoid ambiguity when swapping objects of a Boost type that does
// not have its own boost::swap overload.
#include <cstddef> //for std::size_t
#include <boost/move/utility_core.hpp> //for boost::move
namespace boost_container_swap_move {
template<class T>
void swap(T& left, T& right)
{
T tmp(::boost::move(left));
left = ::boost::move(right);
right = ::boost::move(tmp);
}
} //namespace boost_container_swap_move {
namespace boost_container_swap
{
template<class T>
void adl_swap_impl(T& left, T& right)
{
//use boost_container_swap_move::swap if argument dependent lookup fails
using namespace boost_container_swap_move;
swap(left,right);
}
template<class T, std::size_t N>
void adl_swap_impl(T (& left)[N], T (& right)[N])
{
for (std::size_t i = 0; i < N; ++i){
::boost_container_swap::adl_swap_impl(left[i], right[i]);
}
}
} //namespace boost_container_swap {
namespace boost{
namespace container{
template<class T1, class T2>
void adl_swap(T1& left, T2& right)
{
::boost_container_swap::adl_swap_impl(left, right);
}
} //namespace container{
} //namespace boost{
#endif //#ifndef BOOST_CONTAINER_DETAIL_SWAP_HPP

View File

@@ -20,9 +20,7 @@
#include <boost/container/detail/config_begin.hpp>
#include <boost/container/detail/workaround.hpp>
#include <boost/container/detail/type_traits.hpp>
#include <iterator>
namespace boost {
namespace container {
@@ -58,7 +56,7 @@ struct operator_arrow_proxy<T&>
template <class Iterator, class UnaryFunction>
class transform_iterator
: public UnaryFunction
, public std::iterator
, public boost::container::iterator
< typename Iterator::iterator_category
, typename container_detail::remove_reference<typename UnaryFunction::result_type>::type
, typename Iterator::difference_type
@@ -156,10 +154,10 @@ class transform_iterator
{ return UnaryFunction::operator()(*m_it); }
void advance(typename Iterator::difference_type n)
{ std::advance(m_it, n); }
{ boost::container::iterator_advance(m_it, n); }
typename Iterator::difference_type distance_to(const transform_iterator &other)const
{ return std::distance(other.m_it, m_it); }
{ return boost::container::iterator_distance(other.m_it, m_it); }
};
template <class Iterator, class UnaryFunc>

View File

@@ -25,9 +25,11 @@
#include <boost/container/detail/destroyers.hpp>
#include <boost/container/detail/pair.hpp>
#include <boost/container/detail/type_traits.hpp>
#include <boost/container/detail/algorithm.hpp> //algo_equal(), algo_lexicographical_compare
#include <boost/container/allocator_traits.hpp>
#include <boost/container/options.hpp>
#include <boost/container/detail/compare_functors.hpp>
#include <boost/container/detail/iterator.hpp>
//
#include <boost/intrusive/pointer_traits.hpp>
#include <boost/intrusive/rbtree.hpp>
@@ -44,8 +46,6 @@
#endif
#include <utility> //std::pair
#include <iterator>
#include <algorithm>
namespace boost {
namespace container {
@@ -523,10 +523,10 @@ class tree
typedef key_node_compare<value_compare, Node> KeyNodeCompare;
public:
typedef container_detail::iterator<iiterator, false> iterator;
typedef container_detail::iterator<iiterator, true > const_iterator;
typedef container_detail::reverse_iterator<iterator> reverse_iterator;
typedef container_detail::reverse_iterator<const_iterator> const_reverse_iterator;
typedef container_detail::iterator_from_iiterator<iiterator, false> iterator;
typedef container_detail::iterator_from_iiterator<iiterator, true > const_iterator;
typedef boost::container::reverse_iterator<iterator> reverse_iterator;
typedef boost::container::reverse_iterator<const_iterator> const_reverse_iterator;
tree()
: AllocHolder()
@@ -592,7 +592,7 @@ class tree
else{
//Optimized allocation and construction
this->allocate_many_and_construct
( first, std::distance(first, last)
( first, boost::container::iterator_distance(first, last)
, insert_equal_end_hint_functor<Node, Icont>(this->icont()));
}
}
@@ -628,7 +628,7 @@ class tree
{
//Optimized allocation and construction
this->allocate_many_and_construct
( first, std::distance(first, last)
( first, boost::container::iterator_distance(first, last)
, container_detail::push_back_functor<Node, Icont>(this->icont()));
}
@@ -1145,10 +1145,10 @@ class tree
{ intrusive_tree_proxy_t::rebalance(this->icont()); }
friend bool operator==(const tree& x, const tree& 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()); }
friend bool operator<(const tree& x, const tree& 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()); }
friend bool operator!=(const tree& x, const tree& y)
{ return !(x == y); }

View File

@@ -29,6 +29,7 @@
#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/container/detail/iterator.hpp>
#include <boost/type_traits/is_pod.hpp>
#include <boost/move/core.hpp>
#include <boost/move/utility_core.hpp>
@@ -42,8 +43,7 @@
#include <boost/container/detail/memory_util.hpp>
#include <boost/intrusive/pointer_traits.hpp>
#include <boost/aligned_storage.hpp>
#include <iterator>
#include <utility> //std::distance
namespace boost {
namespace container {
@@ -98,6 +98,7 @@ typename container_detail::enable_if_c
swap(left, right); // may throw
}
*/
namespace container_detail {
template <typename T>
@@ -174,14 +175,14 @@ inline T* iterator_to_pointer(T* i)
{ return i; }
template <class Iterator>
inline typename std::iterator_traits<Iterator>::pointer
inline typename boost::container::iterator_traits<Iterator>::pointer
iterator_to_pointer(const Iterator &i)
{ return i.operator->(); }
template <class Iterator>
inline
typename boost::intrusive::pointer_traits
<typename std::iterator_traits<Iterator>::pointer>::element_type*
<typename boost::container::iterator_traits<Iterator>::pointer>::element_type*
iterator_to_raw_pointer(const Iterator &i)
{ return (to_raw_pointer)((iterator_to_pointer)(i)); }
@@ -304,8 +305,8 @@ template <typename I, typename O>
struct are_contiguous_and_same
{
static const bool is_same_io =
is_same< typename remove_const< typename ::std::iterator_traits<I>::value_type >::type
, typename ::std::iterator_traits<O>::value_type
is_same< typename remove_const< typename ::boost::container::iterator_traits<I>::value_type >::type
, typename ::boost::container::iterator_traits<O>::value_type
>::value;
static const bool value = is_same_io &&
are_elements_contiguous<I>::value &&
@@ -316,14 +317,14 @@ template <typename I, typename O>
struct is_memtransfer_copy_assignable
{
static const bool value = are_contiguous_and_same<I, O>::value &&
boost::has_trivial_assign< typename ::std::iterator_traits<I>::value_type >::value;
boost::has_trivial_assign< typename ::boost::container::iterator_traits<I>::value_type >::value;
};
template <typename I, typename O>
struct is_memtransfer_copy_constructible
{
static const bool value = are_contiguous_and_same<I, O>::value &&
boost::has_trivial_copy< typename ::std::iterator_traits<I>::value_type >::value;
boost::has_trivial_copy< typename ::boost::container::iterator_traits<I>::value_type >::value;
};
template <typename I, typename O, typename R>
@@ -351,51 +352,51 @@ template
typename F> // F models ForwardIterator
inline F memmove(I f, I l, F r) BOOST_CONTAINER_NOEXCEPT
{
typedef typename std::iterator_traits<I>::value_type value_type;
typename std::iterator_traits<I>::difference_type n = std::distance(f, l);
typedef typename boost::container::iterator_traits<I>::value_type value_type;
typename boost::container::iterator_traits<I>::difference_type n = boost::container::iterator_distance(f, l);
::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n);
std::advance(r, n);
boost::container::iterator_advance(r, n);
return r;
}
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
F memmove_n(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
F memmove_n(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
{
typedef typename std::iterator_traits<I>::value_type value_type;
typedef typename boost::container::iterator_traits<I>::value_type value_type;
::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n);
std::advance(r, n);
boost::container::iterator_advance(r, n);
return r;
}
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
I memmove_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
I memmove_n_source(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
{
typedef typename std::iterator_traits<I>::value_type value_type;
typedef typename boost::container::iterator_traits<I>::value_type value_type;
::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n);
std::advance(f, n);
boost::container::iterator_advance(f, n);
return f;
}
template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
I memmove_n_source_dest(I f, typename std::iterator_traits<I>::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT
I memmove_n_source_dest(I f, typename boost::container::iterator_traits<I>::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT
{
typedef typename std::iterator_traits<I>::value_type value_type;
typedef typename boost::container::iterator_traits<I>::value_type value_type;
::memmove((iterator_to_raw_pointer)(r), (iterator_to_raw_pointer)(f), sizeof(value_type)*n);
std::advance(f, n);
std::advance(r, n);
boost::container::iterator_advance(f, n);
boost::container::iterator_advance(r, n);
return f;
}
template <typename O>
struct is_memzero_initializable
{
typedef typename ::std::iterator_traits<O>::value_type value_type;
typedef typename ::boost::container::iterator_traits<O>::value_type value_type;
static const bool value = are_elements_contiguous<O>::value &&
( ::boost::is_integral<value_type>::value || ::boost::is_enum<value_type>::value
#if defined(BOOST_CONTAINER_MEMZEROED_POINTER_IS_NULL)
@@ -487,7 +488,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F, F>::type
uninitialized_move_alloc_n(A &a, I f, typename std::iterator_traits<I>::difference_type n, F r)
uninitialized_move_alloc_n(A &a, I f, typename boost::container::iterator_traits<I>::difference_type n, F r)
{
F back = r;
BOOST_TRY{
@@ -511,7 +512,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, F>::type
uninitialized_move_alloc_n(A &, I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
uninitialized_move_alloc_n(A &, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
{ return container_detail::memmove_n(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -532,7 +533,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F, I>::type
uninitialized_move_alloc_n_source(A &a, I f, typename std::iterator_traits<I>::difference_type n, F r)
uninitialized_move_alloc_n_source(A &a, I f, typename boost::container::iterator_traits<I>::difference_type n, F r)
{
F back = r;
BOOST_TRY{
@@ -556,7 +557,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, I>::type
uninitialized_move_alloc_n_source(A &, I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
uninitialized_move_alloc_n_source(A &, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
{ return container_detail::memmove_n_source(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -622,7 +623,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F, F>::type
uninitialized_copy_alloc_n(A &a, I f, typename std::iterator_traits<I>::difference_type n, F r)
uninitialized_copy_alloc_n(A &a, I f, typename boost::container::iterator_traits<I>::difference_type n, F r)
{
F back = r;
BOOST_TRY{
@@ -646,7 +647,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, F>::type
uninitialized_copy_alloc_n(A &, I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
uninitialized_copy_alloc_n(A &, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
{ return container_detail::memmove_n(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -667,7 +668,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::disable_if_memtransfer_copy_constructible<I, F, I>::type
uninitialized_copy_alloc_n_source(A &a, I f, typename std::iterator_traits<I>::difference_type n, F r)
uninitialized_copy_alloc_n_source(A &a, I f, typename boost::container::iterator_traits<I>::difference_type n, F r)
{
F back = r;
BOOST_TRY{
@@ -691,7 +692,7 @@ template
typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::enable_if_memtransfer_copy_constructible<I, F, I>::type
uninitialized_copy_alloc_n_source(A &, I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
uninitialized_copy_alloc_n_source(A &, I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
{ return container_detail::memmove_n_source(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -736,9 +737,9 @@ template
inline typename container_detail::enable_if_memzero_initializable<F, F>::type
uninitialized_value_init_alloc_n(A &, typename allocator_traits<A>::difference_type n, F r)
{
typedef typename std::iterator_traits<F>::value_type value_type;
typedef typename boost::container::iterator_traits<F>::value_type value_type;
::memset((void*)container_detail::iterator_to_raw_pointer(r), 0, sizeof(value_type)*n);
std::advance(r, n);
boost::container::iterator_advance(r, n);
return r;
}
@@ -885,7 +886,7 @@ template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, F>::type
copy_n(I f, typename std::iterator_traits<I>::difference_type n, F r)
copy_n(I f, typename boost::container::iterator_traits<I>::difference_type n, F r)
{
while (n--) {
*r = *f;
@@ -898,7 +899,7 @@ template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, F>::type
copy_n(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
copy_n(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
{ return container_detail::memmove_n(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -911,7 +912,7 @@ template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, I>::type
copy_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r)
copy_n_source(I f, typename boost::container::iterator_traits<I>::difference_type n, F r)
{
while (n--) {
*r = *f;
@@ -924,7 +925,7 @@ template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, I>::type
copy_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
copy_n_source(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
{ return container_detail::memmove_n_source(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -937,7 +938,7 @@ template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, I>::type
copy_n_source_dest(I f, typename std::iterator_traits<I>::difference_type n, F &r)
copy_n_source_dest(I f, typename boost::container::iterator_traits<I>::difference_type n, F &r)
{
while (n--) {
*r = *f;
@@ -950,7 +951,7 @@ template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, I>::type
copy_n_source_dest(I f, typename std::iterator_traits<I>::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT
copy_n_source_dest(I f, typename boost::container::iterator_traits<I>::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT
{ return container_detail::memmove_n_source_dest(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -989,7 +990,7 @@ template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, F>::type
move_n(I f, typename std::iterator_traits<I>::difference_type n, F r)
move_n(I f, typename boost::container::iterator_traits<I>::difference_type n, F r)
{
while (n--) {
*r = ::boost::move(*f);
@@ -1002,7 +1003,7 @@ template
<typename I, // I models InputIterator
typename F> // F models ForwardIterator
inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, F>::type
move_n(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
move_n(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
{ return container_detail::memmove_n(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -1015,7 +1016,7 @@ template
<typename I // I models InputIterator
,typename F> // F models ForwardIterator
inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, I>::type
move_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r)
move_n_source(I f, typename boost::container::iterator_traits<I>::difference_type n, F r)
{
while (n--) {
*r = ::boost::move(*f);
@@ -1028,7 +1029,7 @@ template
<typename I // I models InputIterator
,typename F> // F models ForwardIterator
inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, I>::type
move_n_source(I f, typename std::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
move_n_source(I f, typename boost::container::iterator_traits<I>::difference_type n, F r) BOOST_CONTAINER_NOEXCEPT
{ return container_detail::memmove_n_source(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -1041,7 +1042,7 @@ template
<typename I // I models InputIterator
,typename F> // F models ForwardIterator
inline typename container_detail::disable_if_memtransfer_copy_assignable<I, F, I>::type
move_n_source_dest(I f, typename std::iterator_traits<I>::difference_type n, F &r)
move_n_source_dest(I f, typename boost::container::iterator_traits<I>::difference_type n, F &r)
{
while (n--) {
*r = ::boost::move(*f);
@@ -1054,7 +1055,7 @@ template
<typename I // I models InputIterator
,typename F> // F models ForwardIterator
inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, I>::type
move_n_source_dest(I f, typename std::iterator_traits<I>::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT
move_n_source_dest(I f, typename boost::container::iterator_traits<I>::difference_type n, F &r) BOOST_CONTAINER_NOEXCEPT
{ return container_detail::memmove_n_source_dest(f, n, r); }
//////////////////////////////////////////////////////////////////////////////
@@ -1066,9 +1067,9 @@ inline typename container_detail::enable_if_memtransfer_copy_assignable<I, F, I>
template
<typename A
,typename I> // I models InputIterator
inline void destroy_alloc_n(A &a, I f, typename std::iterator_traits<I>::difference_type n
inline void destroy_alloc_n(A &a, I f, typename boost::container::iterator_traits<I>::difference_type n
,typename boost::container::container_detail::enable_if_c
< !boost::has_trivial_destructor<typename std::iterator_traits<I>::value_type>::value >::type* = 0)
< !boost::has_trivial_destructor<typename boost::container::iterator_traits<I>::value_type>::value >::type* = 0)
{
while(n--){
allocator_traits<A>::destroy(a, container_detail::iterator_to_raw_pointer(f++));
@@ -1078,9 +1079,9 @@ inline void destroy_alloc_n(A &a, I f, typename std::iterator_traits<I>::differe
template
<typename A
,typename I> // I models InputIterator
inline void destroy_alloc_n(A &, I, typename std::iterator_traits<I>::difference_type
inline void destroy_alloc_n(A &, I, typename boost::container::iterator_traits<I>::difference_type
,typename boost::container::container_detail::enable_if_c
< boost::has_trivial_destructor<typename std::iterator_traits<I>::value_type>::value >::type* = 0)
< boost::has_trivial_destructor<typename boost::container::iterator_traits<I>::value_type>::value >::type* = 0)
{}
//////////////////////////////////////////////////////////////////////////////
@@ -1133,8 +1134,8 @@ inline typename container_detail::enable_if_c
::memcpy(stora_ptr, large_ptr, n_i_bytes);
::memcpy(large_ptr, short_ptr, n_i_bytes);
::memcpy(short_ptr, stora_ptr, n_i_bytes);
std::advance(large_range_f, n_i);
std::advance(short_range_f, n_i);
boost::container::iterator_advance(large_range_f, n_i);
boost::container::iterator_advance(short_range_f, n_i);
boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw
boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i);
}
@@ -1204,8 +1205,8 @@ inline typename container_detail::enable_if_c
::memcpy(stora_ptr, large_ptr, szt_rem);
::memcpy(large_ptr, short_ptr, szt_rem);
::memcpy(short_ptr, stora_ptr, szt_rem);
std::advance(large_range_f, n_i);
std::advance(short_range_f, n_i);
boost::container::iterator_advance(large_range_f, n_i);
boost::container::iterator_advance(short_range_f, n_i);
boost::container::uninitialized_move_alloc_n(a, large_range_f, n_j - n_i, short_range_f); // may throw
boost::container::destroy_alloc_n(a, large_range_f, n_j - n_i);
}

View File

@@ -19,12 +19,11 @@
#include <boost/container/detail/workaround.hpp>
#include <boost/container/container_fwd.hpp>
#include <utility>
#include <functional>
#include <memory>
#include <boost/container/detail/flat_tree.hpp>
#include <boost/type_traits/has_trivial_destructor.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/algorithm.hpp> //equal()
#include <boost/container/allocator_traits.hpp>
#include <boost/container/throw_exception.hpp>
#include <boost/move/utility_core.hpp>
@@ -32,6 +31,9 @@
#include <boost/move/traits.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <utility> //pair
#include <functional> //less
#include <memory> //allocator
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
@@ -967,7 +969,7 @@ class flat_map
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const flat_map& x, const flat_map& 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
//!
@@ -979,7 +981,7 @@ class flat_map
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const flat_map& x, const flat_map& 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
//!
@@ -1868,7 +1870,7 @@ class flat_multimap
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const flat_multimap& x, const flat_multimap& 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
//!
@@ -1880,7 +1882,7 @@ class flat_multimap
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const flat_multimap& x, const flat_multimap& 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
//!

View File

@@ -19,9 +19,6 @@
#include <boost/container/detail/workaround.hpp>
#include <boost/container/container_fwd.hpp>
#include <utility>
#include <functional>
#include <memory>
#include <boost/container/detail/flat_tree.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/container/allocator_traits.hpp>
@@ -29,9 +26,13 @@
#include <boost/move/detail/move_helpers.hpp>
#include <boost/move/traits.hpp>
#include <utility> //pair
#include <functional> //less
#include <memory> //allocator
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
namespace boost {
namespace container {

View File

@@ -20,7 +20,10 @@
#include <boost/container/detail/version_type.hpp>
#include <boost/container/detail/iterators.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/algorithm.hpp>
#include <boost/container/throw_exception.hpp>
#include <boost/container/detail/iterator.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/move/iterator.hpp>
#include <boost/move/detail/move_helpers.hpp>
@@ -38,16 +41,11 @@
#include <boost/container/detail/preprocessor.hpp>
#endif
#include <memory> //std::allocator
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
#include <iterator>
#include <utility>
#include <memory>
#include <functional>
#include <algorithm>
namespace boost {
namespace container {
@@ -149,8 +147,8 @@ class list
BOOST_COPYABLE_AND_MOVABLE(list)
typedef container_detail::iterator<typename Icont::iterator, false> iterator_impl;
typedef container_detail::iterator<typename Icont::iterator, true> const_iterator_impl;
typedef container_detail::iterator_from_iiterator<typename Icont::iterator, false> iterator_impl;
typedef container_detail::iterator_from_iiterator<typename Icont::iterator, true> const_iterator_impl;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
public:
@@ -171,8 +169,8 @@ class list
typedef BOOST_CONTAINER_IMPDEF(NodeAlloc) stored_allocator_type;
typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) 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;
//////////////////////////////////////////////
//
@@ -838,7 +836,7 @@ class list
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced InpIt throws.
//!
//! <b>Complexity</b>: Linear to std::distance [first, last).
//! <b>Complexity</b>: Linear to distance [first, last).
template <class InpIt>
iterator insert(const_iterator p, InpIt first, InpIt last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -878,7 +876,7 @@ class list
insertion_functor func(this->icont(), p.get());
iterator before_p(p.get());
--before_p;
this->allocate_many_and_construct(first, std::distance(first, last), func);
this->allocate_many_and_construct(first, boost::container::iterator_distance(first, last), func);
return ++before_p;
}
#endif
@@ -893,7 +891,7 @@ class list
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced std::initializer_list iterator 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 p, std::initializer_list<value_type> il)
{ return insert(p, il.begin(), il.end()); }
#endif
@@ -1065,7 +1063,7 @@ class list
//! <b>Requires</b>: p must point to an element contained
//! by this list. first and last must point to elements contained in list x.
//! n == std::distance(first, last). this' allocator and x's allocator shall compare equal
//! n == distance(first, last). this' allocator and x's allocator shall compare equal
//!
//! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called.
@@ -1086,7 +1084,7 @@ class list
//! <b>Requires</b>: p must point to an element contained
//! by this list. first and last must point to elements contained in list x.
//! n == std::distance(first, last). this' allocator and x's allocator shall compare equal
//! n == distance(first, last). this' allocator and x's allocator shall compare equal
//!
//! <b>Effects</b>: Transfers the range pointed by first and last from list x to this list,
//! before the the element pointed by p. No destructors or copy constructors are called.
@@ -1270,21 +1268,7 @@ class list
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const list& x, const list& y)
{
if(x.size() != y.size()){
return false;
}
typedef typename list::const_iterator const_iterator;
const_iterator end1 = x.end();
const_iterator i1 = x.begin();
const_iterator i2 = y.begin();
while (i1 != end1 && *i1 == *i2) {
++i1;
++i2;
}
return i1 == end1;
}
{ 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
//!
@@ -1296,7 +1280,7 @@ class list
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const list& x, const list& 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
//!

View File

@@ -19,9 +19,6 @@
#include <boost/container/detail/workaround.hpp>
#include <boost/container/container_fwd.hpp>
#include <utility>
#include <functional>
#include <memory>
#include <boost/container/detail/tree.hpp>
#include <boost/container/detail/value_init.hpp>
#include <boost/type_traits/has_trivial_destructor.hpp>
@@ -37,6 +34,9 @@
#include <boost/container/detail/value_init.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <utility> //pair
#include <functional> //less
#include <memory> //allocator
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif

View File

@@ -28,8 +28,7 @@
#include <boost/assert.hpp>
#include <boost/utility/addressof.hpp>
#include <boost/static_assert.hpp>
#include <memory>
#include <algorithm>
#include <utility>
#include <cstddef>
namespace boost {

View File

@@ -19,10 +19,6 @@
#include <boost/container/detail/workaround.hpp>
#include <boost/container/container_fwd.hpp>
#include <utility>
#include <functional>
#include <memory>
#include <boost/move/utility_core.hpp>
#include <boost/move/detail/move_helpers.hpp>
#include <boost/move/traits.hpp>
@@ -32,6 +28,10 @@
#ifndef BOOST_CONTAINER_PERFECT_FORWARDING
#include <boost/container/detail/preprocessor.hpp>
#endif
#include <utility> //pair
#include <functional> //less
#include <memory> //allocator
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif

View File

@@ -20,19 +20,24 @@
#include <boost/container/container_fwd.hpp>
#include <boost/container/throw_exception.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/move/detail/move_helpers.hpp>
#include <boost/move/traits.hpp>
#include <boost/intrusive/pointer_traits.hpp>
#include <boost/container/detail/utilities.hpp>
#include <boost/container/detail/iterators.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/type_traits.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <boost/container/detail/iterator.hpp>
#include <boost/container/detail/node_alloc_holder.hpp>
#include <boost/container/detail/compare_functors.hpp>
#include <boost/container/detail/algorithm.hpp> //algo_equal(), algo_lexicographical_compare
#include <boost/core/no_exceptions_support.hpp>
#include <boost/intrusive/slist.hpp>
#include <iterator>
#include <boost/move/utility_core.hpp>
#include <boost/move/detail/move_helpers.hpp>
#include <boost/move/traits.hpp>
#include <boost/intrusive/pointer_traits.hpp>
#if defined(BOOST_CONTAINER_PERFECT_FORWARDING) || defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -41,12 +46,7 @@
#include <boost/container/detail/preprocessor.hpp>
#endif
#include <iterator>
#include <utility>
#include <memory>
#include <functional>
#include <algorithm>
#include <memory> //std::allocator
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
@@ -181,8 +181,8 @@ class slist
typedef boost::container::equal_to_value<Allocator> equal_to_value_type;
BOOST_COPYABLE_AND_MOVABLE(slist)
typedef container_detail::iterator<typename Icont::iterator, false> iterator_impl;
typedef container_detail::iterator<typename Icont::iterator, true > const_iterator_impl;
typedef container_detail::iterator_from_iiterator<typename Icont::iterator, false> iterator_impl;
typedef container_detail::iterator_from_iiterator<typename Icont::iterator, true > const_iterator_impl;
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
public:
@@ -875,7 +875,7 @@ class slist
{
//Optimized allocation and construction
insertion_functor func(this->icont(), prev.get());
this->allocate_many_and_construct(first, std::distance(first, last), func);
this->allocate_many_and_construct(first, boost::container::iterator_distance(first, last), func);
return iterator(func.inserted_first());
}
#endif
@@ -1058,7 +1058,7 @@ class slist
//! <b>Requires</b>: prev_p must be a valid iterator of this.
//! before_first and before_last must be valid iterators of x.
//! prev_p must not be contained in [before_first, before_last) range.
//! n == std::distance(before_first, before_last).
//! n == distance(before_first, before_last).
//! this' allocator and x's allocator shall compare equal.
//!
//! <b>Effects</b>: Transfers the range [before_first + 1, before_last + 1)
@@ -1082,7 +1082,7 @@ class slist
//! <b>Requires</b>: prev_p must be a valid iterator of this.
//! before_first and before_last must be valid iterators of x.
//! prev_p must not be contained in [before_first, before_last) range.
//! n == std::distance(before_first, before_last).
//! n == distance(before_first, before_last).
//! this' allocator and x's allocator shall compare equal.
//!
//! <b>Effects</b>: Transfers the range [before_first + 1, before_last + 1)
@@ -1349,7 +1349,7 @@ class slist
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced InpIt throws.
//!
//! <b>Complexity</b>: Linear to std::distance [first, last) plus
//! <b>Complexity</b>: Linear to distance [first, last) plus
//! linear to the elements before p.
template <class InIter>
iterator insert(const_iterator p, InIter first, InIter last)
@@ -1500,21 +1500,7 @@ class slist
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const slist& x, const slist& y)
{
if(x.size() != y.size()){
return false;
}
typedef typename slist<T,Allocator>::const_iterator const_iterator;
const_iterator end1 = x.end();
const_iterator i1 = x.begin();
const_iterator i2 = y.begin();
while (i1 != end1 && *i1 == *i2){
++i1;
++i2;
}
return i1 == end1;
}
{ 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
//!
@@ -1526,7 +1512,7 @@ class slist
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const slist& x, const slist& 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
//!

View File

@@ -31,8 +31,10 @@
#include <boost/container/detail/allocator_version_traits.hpp>
#include <boost/container/detail/utilities.hpp>
#include <boost/container/detail/iterators.hpp>
#include <boost/container/detail/algorithms.hpp>
#include <boost/container/detail/construct_in_place.hpp>
#include <boost/container/detail/algorithm.hpp> //algo_equal(), algo_lexicographical_compare
#include <boost/container/allocator_traits.hpp>
#include <boost/container/detail/iterator.hpp>
#include <boost/container/throw_exception.hpp>
#include <boost/intrusive/pointer_traits.hpp>
#include <boost/core/no_exceptions_support.hpp>
@@ -41,26 +43,22 @@
#include <boost/move/iterator.hpp>
#include <boost/move/detail/move_helpers.hpp>
#include <boost/container/detail/placement_new.hpp>
#include <algorithm>
#include <utility> //std::pair
#include <memory>
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
#include <boost/container/vector.hpp>
//#define STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
#include <boost/container/vector.hpp>
//#define STABLE_VECTOR_ENABLE_INVARIANT_CHECKING
#endif //#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
namespace boost {
namespace container {
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
namespace stable_vector_detail{
@@ -506,8 +504,8 @@ class stable_vector
typedef node_allocator_type stored_allocator_type;
typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) 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
private:
@@ -999,7 +997,7 @@ class stable_vector
size_type size() const BOOST_CONTAINER_NOEXCEPT
{
const size_type index_size = this->index.size();
return (index_size - ExtraPointers) & (std::size_t(0u) -std::size_t(index_size != 0));
return (index_size - ExtraPointers) & (size_type(0u) -size_type(index_size != 0));
}
//! <b>Effects</b>: Returns the largest possible size of the stable_vector.
@@ -1462,7 +1460,7 @@ class stable_vector
//!
//! <b>Returns</b>: an iterator to the first inserted element or p if first == last.
//!
//! <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 p, std::initializer_list<value_type> il)
{
STABLE_VECTOR_CHECK_INVARIANT;
@@ -1479,7 +1477,7 @@ class stable_vector
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced InpIt 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 InputIterator>
iterator insert(const_iterator p, InputIterator first, InputIterator last
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1507,7 +1505,7 @@ class stable_vector
>::type * = 0
)
{
const size_type num_new = static_cast<size_type>(std::distance(first, last));
const size_type num_new = static_cast<size_type>(boost::container::iterator_distance(first, last));
const size_type idx = static_cast<size_type>(p - this->cbegin());
if(num_new){
//Fills the node pool and inserts num_new null pointers in idx.
@@ -1623,7 +1621,7 @@ class stable_vector
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const stable_vector& x, const stable_vector& 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
//!
@@ -1635,7 +1633,7 @@ class stable_vector
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator<(const stable_vector& x, const stable_vector& 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
//!

View File

@@ -20,6 +20,11 @@
#include <boost/container/vector.hpp>
#include <boost/aligned_storage.hpp>
#include <cstddef>
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list>
#endif
namespace boost { namespace container {
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED

View File

@@ -28,18 +28,18 @@
#include <boost/container/allocator_traits.hpp>
#include <boost/container/detail/allocator_version_traits.hpp>
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/iterator.hpp>
#include <boost/move/utility_core.hpp>
#include <boost/static_assert.hpp>
#include <boost/functional/hash.hpp>
#include <boost/intrusive/pointer_traits.hpp>
#include <boost/core/no_exceptions_support.hpp>
#include <algorithm>
#include <functional>
#include <string>
#include <utility>
#include <iterator>
#include <memory>
#include <algorithm>
#include <iosfwd>
#include <istream>
#include <ostream>
@@ -410,7 +410,9 @@ class basic_string_base
{
if(this->is_short()){
if(other.is_short()){
std::swap(this->members_.m_repr, other.members_.m_repr);
repr_t tmp(this->members_.m_repr);
this->members_.m_repr = other.members_.m_repr;
other.members_.m_repr = tmp;
}
else{
short_t short_backup(this->members_.m_repr.short_repr());
@@ -542,8 +544,8 @@ class basic_string
typedef BOOST_CONTAINER_IMPDEF(allocator_type) stored_allocator_type;
typedef BOOST_CONTAINER_IMPDEF(pointer) iterator;
typedef BOOST_CONTAINER_IMPDEF(const_pointer) 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;
static const size_type npos = size_type(-1);
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
@@ -1457,7 +1459,7 @@ class basic_string
{
const size_type n_pos = p - this->cbegin();
if (first != last) {
const size_type n = std::distance(first, last);
const size_type n = boost::container::iterator_distance(first, last);
const size_type old_size = this->priv_size();
const size_type remaining = this->capacity() - old_size;
const pointer old_start = this->priv_addr();
@@ -1500,7 +1502,7 @@ class basic_string
}
else {
ForwardIter mid = first;
std::advance(mid, elems_after + 1);
boost::container::iterator_advance(mid, elems_after + 1);
priv_uninitialized_copy(mid, last, old_start + old_size + 1);
const size_type newer_size = old_size + (n - elems_after);
@@ -1849,7 +1851,7 @@ class basic_string
>::type * = 0
)
{
difference_type n = std::distance(j1, j2);
difference_type n = boost::container::iterator_distance(j1, j2);
const difference_type len = i2 - i1;
if (len >= n) {
this->priv_copy(j1, j2, const_cast<CharT*>(container_detail::to_raw_pointer(i1)));
@@ -1857,7 +1859,7 @@ class basic_string
}
else {
ForwardIter m = j1;
std::advance(m, len);
boost::container::iterator_advance(m, len);
this->priv_copy(j1, m, const_cast<CharT*>(container_detail::to_raw_pointer(i1)));
this->insert(i2, m, j2);
}
@@ -2503,7 +2505,7 @@ class basic_string
InputIter f, InputIter l,
container_detail::false_)
{
typedef typename std::iterator_traits<InputIter>::iterator_category Category;
typedef typename boost::container::iterator_traits<InputIter>::iterator_category Category;
return this->priv_replace(first, last, f, l, Category());
}

View File

@@ -19,14 +19,6 @@
#include <boost/container/detail/workaround.hpp>
#include <boost/container/container_fwd.hpp>
//#include <cstddef> //Already included by container_fwd.hpp
#include <memory> //for std::allocator
#include <iterator> //for std::random_access_iterator_tag
#include <utility> //for std::pair,std::distance
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list> //for std::initializer_list
#endif
#include <boost/core/no_exceptions_support.hpp>
#include <boost/assert.hpp>
#include <boost/move/utility_core.hpp>
@@ -46,6 +38,8 @@
#include <boost/container/detail/mpl.hpp>
#include <boost/container/detail/type_traits.hpp>
#include <boost/container/detail/advanced_insert_int.hpp>
#include <boost/container/detail/algorithm.hpp> //equal()
#include <boost/container/detail/iterator.hpp>
#include <boost/intrusive/pointer_traits.hpp>
@@ -56,6 +50,12 @@
#include <boost/type_traits/has_nothrow_assign.hpp>
#include <boost/type_traits/has_nothrow_constructor.hpp>
#include <memory> //for std::allocator
#include <utility> //for std::pair
#if !defined(BOOST_NO_CXX11_HDR_INITIALIZER_LIST)
#include <initializer_list> //for std::initializer_list
#endif
namespace boost {
namespace container {
@@ -505,7 +505,7 @@ struct vector_alloc_holder<Allocator, container_detail::integral_constant<unsign
template<class OtherAllocator, class OtherAllocatorVersion>
void priv_swap_members_impl(vector_alloc_holder<OtherAllocator, OtherAllocatorVersion> &x)
{
const std::size_t MaxTmpStorage = sizeof(value_type)*Allocator::internal_capacity;
const size_type MaxTmpStorage = sizeof(value_type)*Allocator::internal_capacity;
value_type *const first_this = container_detail::to_raw_pointer(this->start());
value_type *const first_x = container_detail::to_raw_pointer(x.start());
@@ -571,8 +571,8 @@ class vector
typedef BOOST_CONTAINER_IMPDEF(iterator_impl) iterator;
typedef BOOST_CONTAINER_IMPDEF(const_iterator_impl) const_iterator;
#endif
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
private:
@@ -981,7 +981,7 @@ class vector
{
//For Fwd iterators the standard only requires EmplaceConstructible and assignable from *first
//so we can't do any backwards allocation
const size_type input_sz = static_cast<size_type>(std::distance(first, last));
const size_type input_sz = static_cast<size_type>(boost::container::iterator_distance(first, last));
const size_type old_capacity = this->capacity();
if(input_sz > old_capacity){ //If input range is too big, we need to reallocate
size_type real_cap = 0;
@@ -1608,7 +1608,7 @@ class vector
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced InpIt throws or T's copy/move constructor/assignment throws.
//!
//! <b>Complexity</b>: Linear to std::distance [first, last).
//! <b>Complexity</b>: Linear to boost::container::iterator_distance [first, last).
template <class InIt>
iterator insert(const_iterator pos, InIt first, InIt last
BOOST_CONTAINER_DOCIGN(BOOST_CONTAINER_I typename container_detail::enable_if_c
@@ -1636,12 +1636,12 @@ class vector
)
{
container_detail::insert_range_proxy<Allocator, FwdIt, T*> proxy(first);
return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), std::distance(first, last), proxy, alloc_version());
return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), boost::container::iterator_distance(first, last), proxy, alloc_version());
}
#endif
//! <b>Requires</b>: p must be a valid iterator of *this. num, must
//! be equal to std::distance(first, last)
//! be equal to boost::container::iterator_distance(first, last)
//!
//! <b>Effects</b>: Insert a copy of the [first, last) range before pos.
//!
@@ -1650,9 +1650,9 @@ class vector
//! <b>Throws</b>: If memory allocation throws, T's constructor from a
//! dereferenced InpIt throws or T's copy/move constructor/assignment throws.
//!
//! <b>Complexity</b>: Linear to std::distance [first, last).
//! <b>Complexity</b>: Linear to boost::container::iterator_distance [first, last).
//!
//! <b>Note</b>: This function avoids a linear operation to calculate std::distance[first, last)
//! <b>Note</b>: This function avoids a linear operation to calculate boost::container::iterator_distance[first, last)
//! for forward and bidirectional iterators, and a one by one insertion for input iterators. This is a
//! a non-standard extension.
#if !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
@@ -1660,7 +1660,7 @@ class vector
iterator insert(const_iterator pos, size_type num, InIt first, InIt last)
{
BOOST_ASSERT(container_detail::is_input_iterator<InIt>::value ||
num == static_cast<size_type>(std::distance(first, last)));
num == static_cast<size_type>(boost::container::iterator_distance(first, last)));
(void)last;
container_detail::insert_range_proxy<Allocator, InIt, T*> proxy(first);
return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), num, proxy, alloc_version());
@@ -1772,21 +1772,7 @@ class vector
//!
//! <b>Complexity</b>: Linear to the number of elements in the container.
friend bool operator==(const vector& x, const vector& y)
{
if(x.size() != y.size()){
return false;
}
else{
const_iterator first1(x.cbegin()), first2(y.cbegin());
const const_iterator last1(x.cend());
for (; first1 != last1; ++first1, ++first2) {
if (*first1 != *first2) {
return false;
}
}
return true;
}
}
{ 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
//!
@@ -2464,7 +2450,7 @@ class vector
while(insertions_left){
if(do_skip){
size_type n = *(--last_skip_it);
std::advance(last_value_it, -difference_type(n));
boost::container::iterator_advance(last_value_it, -difference_type(n));
}
const size_type pos = static_cast<size_type>(*(--last_position_it));
BOOST_ASSERT(pos <= old_size_pos);