mirror of
https://github.com/boostorg/container.git
synced 2025-08-03 14:34:27 +02:00
Add experimental option to define "vector::iterator" as "pointer"
[SVN r83140]
This commit is contained in:
@@ -33,6 +33,9 @@
|
|||||||
#include <boost/container/detail/value_init.hpp>
|
#include <boost/container/detail/value_init.hpp>
|
||||||
#include <boost/container/detail/destroyers.hpp>
|
#include <boost/container/detail/destroyers.hpp>
|
||||||
#include <boost/container/allocator_traits.hpp>
|
#include <boost/container/allocator_traits.hpp>
|
||||||
|
#ifdef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||||
|
#include <boost/intrusive/pointer_traits.hpp>
|
||||||
|
#endif
|
||||||
#include <boost/aligned_storage.hpp>
|
#include <boost/aligned_storage.hpp>
|
||||||
|
|
||||||
namespace boost {
|
namespace boost {
|
||||||
@@ -73,10 +76,19 @@ class flat_tree_value_compare
|
|||||||
template<class Pointer>
|
template<class Pointer>
|
||||||
struct get_flat_tree_iterators
|
struct get_flat_tree_iterators
|
||||||
{
|
{
|
||||||
|
#ifdef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||||
|
typedef Pointer iterator;
|
||||||
|
typedef typename boost::intrusive::
|
||||||
|
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;
|
||||||
|
#else //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||||
typedef typename container_detail::
|
typedef typename container_detail::
|
||||||
vector_iterator<Pointer> iterator;
|
vector_iterator<Pointer> iterator;
|
||||||
typedef typename container_detail::
|
typedef typename container_detail::
|
||||||
vector_const_iterator<Pointer> const_iterator;
|
vector_const_iterator<Pointer> const_iterator;
|
||||||
|
#endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||||
typedef std::reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
};
|
};
|
||||||
@@ -785,7 +797,7 @@ class flat_tree
|
|||||||
const value_compare &value_comp = this->m_data;
|
const value_compare &value_comp = this->m_data;
|
||||||
commit_data.position = this->priv_lower_bound(b, e, KeyOfValue()(val));
|
commit_data.position = this->priv_lower_bound(b, e, KeyOfValue()(val));
|
||||||
return std::pair<iterator,bool>
|
return std::pair<iterator,bool>
|
||||||
( *reinterpret_cast<iterator*>(&commit_data.position)
|
( iterator(vector_iterator_get_ptr(commit_data.position))
|
||||||
, commit_data.position == e || value_comp(val, *commit_data.position));
|
, commit_data.position == e || value_comp(val, *commit_data.position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,10 +825,10 @@ class flat_tree
|
|||||||
if(pos != this->cbegin() && !value_comp(val, pos[-1])){
|
if(pos != this->cbegin() && !value_comp(val, pos[-1])){
|
||||||
if(value_comp(pos[-1], val)){
|
if(value_comp(pos[-1], val)){
|
||||||
commit_data.position = pos;
|
commit_data.position = pos;
|
||||||
return std::pair<iterator,bool>(*reinterpret_cast<iterator*>(&pos), true);
|
return std::pair<iterator,bool>(iterator(vector_iterator_get_ptr(pos)), true);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
return std::pair<iterator,bool>(*reinterpret_cast<iterator*>(&pos), false);
|
return std::pair<iterator,bool>(iterator(vector_iterator_get_ptr(pos)), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this->priv_insert_unique_prepare(this->cbegin(), pos, val, commit_data);
|
return this->priv_insert_unique_prepare(this->cbegin(), pos, val, commit_data);
|
||||||
|
@@ -333,7 +333,8 @@ struct index_traits
|
|||||||
static void readjust_end_node(index_type &index, node_base_type &end_node)
|
static void readjust_end_node(index_type &index, node_base_type &end_node)
|
||||||
{
|
{
|
||||||
if(!index.empty()){
|
if(!index.empty()){
|
||||||
node_base_ptr &end_node_idx_ref = *(--index_traits::get_fix_up_end(index));
|
index_iterator end_node_it(index_traits::get_fix_up_end(index));
|
||||||
|
node_base_ptr &end_node_idx_ref = *(--end_node_it);
|
||||||
end_node_idx_ref = node_base_ptr_traits::pointer_to(end_node);
|
end_node_idx_ref = node_base_ptr_traits::pointer_to(end_node);
|
||||||
end_node.up = node_base_ptr_ptr_traits::pointer_to(end_node_idx_ref);
|
end_node.up = node_base_ptr_ptr_traits::pointer_to(end_node_idx_ref);
|
||||||
}
|
}
|
||||||
|
@@ -55,8 +55,12 @@ namespace container {
|
|||||||
|
|
||||||
/// @cond
|
/// @cond
|
||||||
|
|
||||||
|
//#define BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||||
|
|
||||||
namespace container_detail {
|
namespace container_detail {
|
||||||
|
|
||||||
|
#ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||||
|
|
||||||
//! Const vector_iterator used to iterate through a vector.
|
//! Const vector_iterator used to iterate through a vector.
|
||||||
template <class Pointer>
|
template <class Pointer>
|
||||||
class vector_const_iterator
|
class vector_const_iterator
|
||||||
@@ -221,6 +225,57 @@ class vector_iterator
|
|||||||
{ left.m_ptr -= off; return left; }
|
{ left.m_ptr -= off; return left; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} //namespace container_detail {
|
||||||
|
|
||||||
|
template<class Pointer>
|
||||||
|
const Pointer &vector_iterator_get_ptr(const container_detail::vector_const_iterator<Pointer> &it) BOOST_CONTAINER_NOEXCEPT
|
||||||
|
{ return it.get_ptr(); }
|
||||||
|
|
||||||
|
template<class Pointer>
|
||||||
|
Pointer &get_ptr(container_detail::vector_const_iterator<Pointer> &it) BOOST_CONTAINER_NOEXCEPT
|
||||||
|
{ return it.get_ptr(); }
|
||||||
|
|
||||||
|
namespace container_detail {
|
||||||
|
|
||||||
|
#else //ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||||
|
|
||||||
|
template< class MaybeConstPointer
|
||||||
|
, bool ElementTypeIsConst
|
||||||
|
= is_const< typename boost::intrusive::pointer_traits<MaybeConstPointer>::element_type>::value >
|
||||||
|
struct vector_get_ptr_pointer_to_non_const
|
||||||
|
{
|
||||||
|
typedef MaybeConstPointer const_pointer;
|
||||||
|
typedef boost::intrusive::pointer_traits<const_pointer> pointer_traits_t;
|
||||||
|
typedef typename pointer_traits_t::element_type element_type;
|
||||||
|
typedef typename remove_const<element_type>::type non_const_element_type;
|
||||||
|
typedef typename pointer_traits_t
|
||||||
|
::template rebind_pointer<non_const_element_type>::type return_type;
|
||||||
|
|
||||||
|
static return_type get_ptr(const const_pointer &ptr)
|
||||||
|
{ return boost::intrusive::pointer_traits<return_type>::const_cast_from(ptr); }
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class Pointer>
|
||||||
|
struct vector_get_ptr_pointer_to_non_const<Pointer, false>
|
||||||
|
{
|
||||||
|
typedef const Pointer & return_type;
|
||||||
|
static return_type get_ptr(const Pointer &ptr)
|
||||||
|
{ return ptr; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} //namespace container_detail {
|
||||||
|
|
||||||
|
template<class MaybeConstPointer>
|
||||||
|
typename container_detail::vector_get_ptr_pointer_to_non_const<MaybeConstPointer>::return_type
|
||||||
|
vector_iterator_get_ptr(const MaybeConstPointer &ptr) BOOST_CONTAINER_NOEXCEPT
|
||||||
|
{
|
||||||
|
return container_detail::vector_get_ptr_pointer_to_non_const<MaybeConstPointer>::get_ptr(ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace container_detail {
|
||||||
|
|
||||||
|
#endif //#ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||||
|
|
||||||
template <class T, class Allocator>
|
template <class T, class Allocator>
|
||||||
struct vector_value_traits
|
struct vector_value_traits
|
||||||
{
|
{
|
||||||
@@ -323,7 +378,6 @@ struct vector_alloc_holder
|
|||||||
void first_allocation_same_allocator_type(size_type cap)
|
void first_allocation_same_allocator_type(size_type cap)
|
||||||
{ this->first_allocation(cap); }
|
{ this->first_allocation(cap); }
|
||||||
|
|
||||||
//Destructor
|
|
||||||
~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT
|
~vector_alloc_holder() BOOST_CONTAINER_NOEXCEPT
|
||||||
{
|
{
|
||||||
if(this->m_capacity){
|
if(this->m_capacity){
|
||||||
@@ -359,9 +413,6 @@ struct vector_alloc_holder
|
|||||||
container_detail::do_swap(this->m_start, x.m_start);
|
container_detail::do_swap(this->m_start, x.m_start);
|
||||||
container_detail::do_swap(this->m_size, x.m_size);
|
container_detail::do_swap(this->m_size, x.m_size);
|
||||||
container_detail::do_swap(this->m_capacity, x.m_capacity);
|
container_detail::do_swap(this->m_capacity, x.m_capacity);
|
||||||
//And now the allocator
|
|
||||||
container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag;
|
|
||||||
container_detail::swap_alloc(this->alloc(), x.alloc(), flag);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT
|
void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT
|
||||||
@@ -389,10 +440,10 @@ struct vector_alloc_holder
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const pointer &start() const { return m_start; }
|
const pointer &start() const BOOST_CONTAINER_NOEXCEPT { return m_start; }
|
||||||
const size_type &capacity() const { return m_capacity; }
|
const size_type &capacity() const BOOST_CONTAINER_NOEXCEPT { return m_capacity; }
|
||||||
void start(const pointer &p) { m_start = p; }
|
void start(const pointer &p) BOOST_CONTAINER_NOEXCEPT { m_start = p; }
|
||||||
void capacity(const size_type &c) { m_capacity = c; }
|
void capacity(const size_type &c) BOOST_CONTAINER_NOEXCEPT { m_capacity = c; }
|
||||||
};
|
};
|
||||||
|
|
||||||
//!This struct deallocates and allocated memory
|
//!This struct deallocates and allocated memory
|
||||||
@@ -468,7 +519,7 @@ struct vector_alloc_holder<Allocator, container_detail::integral_constant<unsign
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void first_allocation_same_allocator_type(size_type)
|
void first_allocation_same_allocator_type(size_type) BOOST_CONTAINER_NOEXCEPT
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//Destructor
|
//Destructor
|
||||||
@@ -489,7 +540,7 @@ struct vector_alloc_holder<Allocator, container_detail::integral_constant<unsign
|
|||||||
this->priv_swap_members_impl(x);
|
this->priv_swap_members_impl(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
void move_from_empty(vector_alloc_holder &x) BOOST_CONTAINER_NOEXCEPT
|
void move_from_empty(vector_alloc_holder &x)
|
||||||
{ //Containers with version 0 allocators can't be moved without move elements one by one
|
{ //Containers with version 0 allocators can't be moved without move elements one by one
|
||||||
throw_bad_alloc();
|
throw_bad_alloc();
|
||||||
}
|
}
|
||||||
@@ -503,8 +554,8 @@ struct vector_alloc_holder<Allocator, container_detail::integral_constant<unsign
|
|||||||
void deallocate() BOOST_CONTAINER_NOEXCEPT
|
void deallocate() BOOST_CONTAINER_NOEXCEPT
|
||||||
{}
|
{}
|
||||||
|
|
||||||
pointer start() const { return Allocator::internal_storage(); }
|
pointer start() const BOOST_CONTAINER_NOEXCEPT { return Allocator::internal_storage(); }
|
||||||
size_type capacity() const { return Allocator::internal_capacity; }
|
size_type capacity() const BOOST_CONTAINER_NOEXCEPT { return Allocator::internal_capacity; }
|
||||||
size_type m_size;
|
size_type m_size;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -542,11 +593,11 @@ template <class T, class Allocator>
|
|||||||
#endif
|
#endif
|
||||||
class vector
|
class vector
|
||||||
{
|
{
|
||||||
|
/// @cond
|
||||||
typedef container_detail::integral_constant
|
typedef container_detail::integral_constant
|
||||||
<unsigned, boost::container::container_detail::version
|
<unsigned, boost::container::container_detail::version
|
||||||
<Allocator>::value > alloc_version;
|
<Allocator>::value > alloc_version;
|
||||||
boost::container::container_detail::vector_alloc_holder<Allocator, alloc_version> m_holder;
|
boost::container::container_detail::vector_alloc_holder<Allocator, alloc_version> m_holder;
|
||||||
/// @cond
|
|
||||||
typedef container_detail::vector_alloc_holder<Allocator> base_t;
|
typedef container_detail::vector_alloc_holder<Allocator> base_t;
|
||||||
typedef allocator_traits<Allocator> allocator_traits_type;
|
typedef allocator_traits<Allocator> allocator_traits_type;
|
||||||
template <class U, class UAllocator>
|
template <class U, class UAllocator>
|
||||||
@@ -568,8 +619,13 @@ class vector
|
|||||||
typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
|
typedef typename ::boost::container::allocator_traits<Allocator>::difference_type difference_type;
|
||||||
typedef Allocator allocator_type;
|
typedef Allocator allocator_type;
|
||||||
typedef Allocator stored_allocator_type;
|
typedef Allocator stored_allocator_type;
|
||||||
|
#if defined BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER && !defined(BOOST_CONTAINER_DOXYGEN_INVOKED)
|
||||||
|
typedef BOOST_CONTAINER_IMPDEF(pointer) iterator;
|
||||||
|
typedef BOOST_CONTAINER_IMPDEF(const_pointer) const_iterator;
|
||||||
|
#else
|
||||||
typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_iterator<pointer>) iterator;
|
typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_iterator<pointer>) iterator;
|
||||||
typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_const_iterator<pointer>) const_iterator;
|
typedef BOOST_CONTAINER_IMPDEF(container_detail::vector_const_iterator<pointer>) const_iterator;
|
||||||
|
#endif
|
||||||
typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
|
typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<iterator>) reverse_iterator;
|
||||||
typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
|
typedef BOOST_CONTAINER_IMPDEF(std::reverse_iterator<const_iterator>) const_reverse_iterator;
|
||||||
|
|
||||||
@@ -844,7 +900,7 @@ class vector
|
|||||||
if (first == last){
|
if (first == last){
|
||||||
//There are no more elements in the sequence, erase remaining
|
//There are no more elements in the sequence, erase remaining
|
||||||
T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size;
|
T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size;
|
||||||
size_type n = static_cast<size_type>(end_pos - container_detail::to_raw_pointer(cur.get_ptr()));
|
size_type n = static_cast<size_type>(end_pos - container_detail::to_raw_pointer(vector_iterator_get_ptr(cur)));
|
||||||
this->priv_destroy_last_n(n);
|
this->priv_destroy_last_n(n);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -1243,7 +1299,7 @@ class vector
|
|||||||
else{
|
else{
|
||||||
typedef container_detail::insert_emplace_proxy<Allocator, T*, Args...> type;
|
typedef container_detail::insert_emplace_proxy<Allocator, T*, Args...> type;
|
||||||
this->priv_forward_range_insert_no_capacity
|
this->priv_forward_range_insert_no_capacity
|
||||||
(this->cend().get_ptr(), 1, type(this->m_holder.alloc(), ::boost::forward<Args>(args)...), alloc_version());
|
(vector_iterator_get_ptr(this->cend()), 1, type(this->m_holder.alloc(), ::boost::forward<Args>(args)...), alloc_version());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1262,7 +1318,7 @@ class vector
|
|||||||
{
|
{
|
||||||
//Just call more general insert(pos, size, value) and return iterator
|
//Just call more general insert(pos, size, value) and return iterator
|
||||||
typedef container_detail::insert_emplace_proxy<Allocator, T*, Args...> type;
|
typedef container_detail::insert_emplace_proxy<Allocator, T*, Args...> type;
|
||||||
return this->priv_forward_range_insert( position.get_ptr(), 1, type(this->m_holder.alloc()
|
return this->priv_forward_range_insert( vector_iterator_get_ptr(position), 1, type(this->m_holder.alloc()
|
||||||
, ::boost::forward<Args>(args)...), alloc_version());
|
, ::boost::forward<Args>(args)...), alloc_version());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1284,7 +1340,7 @@ class vector
|
|||||||
<Allocator, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
|
<Allocator, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
|
||||||
(this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
|
(this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
|
||||||
this->priv_forward_range_insert_no_capacity \
|
this->priv_forward_range_insert_no_capacity \
|
||||||
(this->cend().get_ptr(), 1, proxy, alloc_version()); \
|
(vector_iterator_get_ptr(this->cend()), 1, proxy, alloc_version()); \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
@@ -1296,7 +1352,7 @@ class vector
|
|||||||
<Allocator, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
|
<Allocator, T* BOOST_PP_ENUM_TRAILING_PARAMS(n, P)> proxy \
|
||||||
(this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
|
(this->m_holder.alloc() BOOST_PP_ENUM_TRAILING(n, BOOST_CONTAINER_PP_PARAM_FORWARD, _)); \
|
||||||
return this->priv_forward_range_insert \
|
return this->priv_forward_range_insert \
|
||||||
(container_detail::to_raw_pointer(pos.get_ptr()), 1, proxy, alloc_version()); \
|
(container_detail::to_raw_pointer(vector_iterator_get_ptr(pos)), 1, proxy, alloc_version()); \
|
||||||
} \
|
} \
|
||||||
//!
|
//!
|
||||||
#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
|
#define BOOST_PP_LOCAL_LIMITS (0, BOOST_CONTAINER_MAX_CONSTRUCTOR_PARAMETERS)
|
||||||
@@ -1361,7 +1417,7 @@ class vector
|
|||||||
iterator insert(const_iterator p, size_type n, const T& x)
|
iterator insert(const_iterator p, size_type n, const T& x)
|
||||||
{
|
{
|
||||||
container_detail::insert_n_copies_proxy<Allocator, T*> proxy(this->m_holder.alloc(), x);
|
container_detail::insert_n_copies_proxy<Allocator, T*> proxy(this->m_holder.alloc(), x);
|
||||||
return this->priv_forward_range_insert(p.get_ptr(), n, proxy, alloc_version());
|
return this->priv_forward_range_insert(vector_iterator_get_ptr(p), n, proxy, alloc_version());
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <b>Requires</b>: p must be a valid iterator of *this.
|
//! <b>Requires</b>: p must be a valid iterator of *this.
|
||||||
@@ -1385,7 +1441,7 @@ class vector
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
const size_type n_pos = pos - this->cbegin();
|
const size_type n_pos = pos - this->cbegin();
|
||||||
iterator it(pos.get_ptr());
|
iterator it(vector_iterator_get_ptr(pos));
|
||||||
for(;first != last; ++first){
|
for(;first != last; ++first){
|
||||||
it = this->emplace(it, *first);
|
it = this->emplace(it, *first);
|
||||||
++it;
|
++it;
|
||||||
@@ -1403,7 +1459,7 @@ class vector
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
container_detail::insert_range_proxy<Allocator, FwdIt, T*> proxy(this->m_holder.alloc(), first);
|
container_detail::insert_range_proxy<Allocator, FwdIt, T*> proxy(this->m_holder.alloc(), first);
|
||||||
return this->priv_forward_range_insert(pos.get_ptr(), std::distance(first, last), proxy, alloc_version());
|
return this->priv_forward_range_insert(vector_iterator_get_ptr(pos), std::distance(first, last), proxy, alloc_version());
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1427,12 +1483,12 @@ class vector
|
|||||||
//! last element. Constant if pos is the last element.
|
//! last element. Constant if pos is the last element.
|
||||||
iterator erase(const_iterator position)
|
iterator erase(const_iterator position)
|
||||||
{
|
{
|
||||||
T *const pos = container_detail::to_raw_pointer(position.get_ptr());
|
T *const pos = container_detail::to_raw_pointer(vector_iterator_get_ptr(position));
|
||||||
T *const beg = container_detail::to_raw_pointer(this->m_holder.start());
|
T *const beg = container_detail::to_raw_pointer(this->m_holder.start());
|
||||||
//Move elements forward and destroy last
|
//Move elements forward and destroy last
|
||||||
this->priv_destroy(::boost::move(pos + 1, beg + this->m_holder.m_size, pos));
|
this->priv_destroy(::boost::move(pos + 1, beg + this->m_holder.m_size, pos));
|
||||||
--this->m_holder.m_size;
|
--this->m_holder.m_size;
|
||||||
return iterator(position.get_ptr());
|
return iterator(vector_iterator_get_ptr(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <b>Effects</b>: Erases the elements pointed by [first, last).
|
//! <b>Effects</b>: Erases the elements pointed by [first, last).
|
||||||
@@ -1446,15 +1502,15 @@ class vector
|
|||||||
if (first != last){
|
if (first != last){
|
||||||
T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size;
|
T* const end_pos = container_detail::to_raw_pointer(this->m_holder.start()) + this->m_holder.m_size;
|
||||||
T* const ptr = container_detail::to_raw_pointer(boost::move
|
T* const ptr = container_detail::to_raw_pointer(boost::move
|
||||||
(container_detail::to_raw_pointer(last.get_ptr())
|
(container_detail::to_raw_pointer(vector_iterator_get_ptr(last))
|
||||||
,end_pos
|
,end_pos
|
||||||
,container_detail::to_raw_pointer(first.get_ptr())
|
,container_detail::to_raw_pointer(vector_iterator_get_ptr(first))
|
||||||
));
|
));
|
||||||
const size_type destroyed = (end_pos - ptr);
|
const size_type destroyed = (end_pos - ptr);
|
||||||
destroy_alloc_n(this->get_stored_allocator(), ptr, destroyed);
|
destroy_alloc_n(this->get_stored_allocator(), ptr, destroyed);
|
||||||
this->m_holder.m_size -= destroyed;
|
this->m_holder.m_size -= destroyed;
|
||||||
}
|
}
|
||||||
return iterator(first.get_ptr());
|
return iterator(vector_iterator_get_ptr(first));
|
||||||
}
|
}
|
||||||
|
|
||||||
//! <b>Effects</b>: Swaps the contents of *this and x.
|
//! <b>Effects</b>: Swaps the contents of *this and x.
|
||||||
@@ -1466,6 +1522,9 @@ class vector
|
|||||||
{
|
{
|
||||||
//Just swap internals in case of !allocator_v0. Otherwise, deep swap
|
//Just swap internals in case of !allocator_v0. Otherwise, deep swap
|
||||||
this->m_holder.swap(x.m_holder);
|
this->m_holder.swap(x.m_holder);
|
||||||
|
//And now the allocator
|
||||||
|
container_detail::bool_<allocator_traits_type::propagate_on_container_swap::value> flag;
|
||||||
|
container_detail::swap_alloc(this->m_holder.alloc(), x.m_holder.alloc(), flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
#ifndef BOOST_CONTAINER_DOXYGEN_INVOKED
|
||||||
@@ -1738,7 +1797,7 @@ class vector
|
|||||||
iterator priv_insert(const const_iterator &p, BOOST_FWD_REF(U) x)
|
iterator priv_insert(const const_iterator &p, BOOST_FWD_REF(U) x)
|
||||||
{
|
{
|
||||||
return this->priv_forward_range_insert
|
return this->priv_forward_range_insert
|
||||||
( p.get_ptr(), 1, container_detail::get_insert_value_proxy<T*>(this->m_holder.alloc()
|
( vector_iterator_get_ptr(p), 1, container_detail::get_insert_value_proxy<T*>(this->m_holder.alloc()
|
||||||
, ::boost::forward<U>(x)), alloc_version());
|
, ::boost::forward<U>(x)), alloc_version());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1754,7 +1813,7 @@ class vector
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
container_detail::insert_copy_proxy<Allocator, T*> proxy(this->m_holder.alloc(), x);
|
container_detail::insert_copy_proxy<Allocator, T*> proxy(this->m_holder.alloc(), x);
|
||||||
this->priv_forward_range_insert_no_capacity(this->cend().get_ptr(), 1, proxy, alloc_version());
|
this->priv_forward_range_insert_no_capacity(vector_iterator_get_ptr(this->cend()), 1, proxy, alloc_version());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1770,7 +1829,7 @@ class vector
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
container_detail::insert_move_proxy<Allocator, T*> proxy(this->m_holder.alloc(), x);
|
container_detail::insert_move_proxy<Allocator, T*> proxy(this->m_holder.alloc(), x);
|
||||||
this->priv_forward_range_insert_no_capacity(this->cend().get_ptr(), 1, proxy, alloc_version());
|
this->priv_forward_range_insert_no_capacity(vector_iterator_get_ptr(this->cend()), 1, proxy, alloc_version());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1907,7 +1966,7 @@ class vector
|
|||||||
iterator priv_forward_range_insert_at_end
|
iterator priv_forward_range_insert_at_end
|
||||||
(const size_type n, const InsertionProxy insert_range_proxy, allocator_v1)
|
(const size_type n, const InsertionProxy insert_range_proxy, allocator_v1)
|
||||||
{
|
{
|
||||||
return this->priv_forward_range_insert(this->cend().get_ptr(), n, insert_range_proxy, allocator_v1());
|
return this->priv_forward_range_insert(vector_iterator_get_ptr(this->cend()), n, insert_range_proxy, allocator_v1());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class InsertionProxy>
|
template <class InsertionProxy>
|
||||||
@@ -1983,7 +2042,7 @@ class vector
|
|||||||
iterator priv_forward_range_insert_at_end
|
iterator priv_forward_range_insert_at_end
|
||||||
(const size_type n, const InsertionProxy insert_range_proxy, allocator_v2)
|
(const size_type n, const InsertionProxy insert_range_proxy, allocator_v2)
|
||||||
{
|
{
|
||||||
return this->priv_forward_range_insert(this->cend().get_ptr(), n, insert_range_proxy, allocator_v2());
|
return this->priv_forward_range_insert(vector_iterator_get_ptr(this->cend()), n, insert_range_proxy, allocator_v2());
|
||||||
}
|
}
|
||||||
|
|
||||||
//Absolutely experimental. This function might change, disappear or simply crash!
|
//Absolutely experimental. This function might change, disappear or simply crash!
|
||||||
|
134
proj/vc7ide/bench_static_vector.vcproj
Normal file
134
proj/vc7ide/bench_static_vector.vcproj
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="7.10"
|
||||||
|
Name="bench_static_vector"
|
||||||
|
ProjectGUID="{55E1C1C3-84FE-26A9-4A2E-D7901C32BA02}"
|
||||||
|
Keyword="Win32Proj">
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"/>
|
||||||
|
</Platforms>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="Debug|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Debug"
|
||||||
|
IntermediateDirectory="Debug/bench_static_vector"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
MinimalRebuild="TRUE"
|
||||||
|
ExceptionHandling="TRUE"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="3"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/bench_static_vector_d.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
ProgramDatabaseFile="$(OutDir)/bench_static_vector.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
TargetMachine="1"
|
||||||
|
FixedBaseAddress="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
<Configuration
|
||||||
|
Name="Release|Win32"
|
||||||
|
OutputDirectory="../../Bin/Win32/Release"
|
||||||
|
IntermediateDirectory="Release/bench_static_vector"
|
||||||
|
ConfigurationType="1"
|
||||||
|
CharacterSet="2">
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories="../../../.."
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;BOOST_DATE_TIME_NO_LIB"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
TreatWChar_tAsBuiltInType="TRUE"
|
||||||
|
ForceConformanceInForLoopScope="FALSE"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="4"
|
||||||
|
Detect64BitPortabilityProblems="TRUE"
|
||||||
|
DebugInformationFormat="0"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="winmm.lib"
|
||||||
|
OutputFile="$(OutDir)/bench_static_vector.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../../../stage/lib"
|
||||||
|
GenerateDebugInformation="TRUE"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
TargetMachine="1"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPostBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebDeploymentTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedWrapperGeneratorTool"/>
|
||||||
|
<Tool
|
||||||
|
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||||
|
</Configuration>
|
||||||
|
</Configurations>
|
||||||
|
<References>
|
||||||
|
</References>
|
||||||
|
<Files>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{437B79CF-06A6-C58A-4312-37D42A302ADF}">
|
||||||
|
<File
|
||||||
|
RelativePath="..\..\bench\bench_static_vector.cpp">
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
@@ -179,14 +179,14 @@ int map_test ()
|
|||||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||||
|
|
||||||
typename MyBoostMap::iterator it;
|
typename MyBoostMap::iterator it = boostmap->begin();
|
||||||
typename MyBoostMap::const_iterator cit = it;
|
typename MyBoostMap::const_iterator cit = it;
|
||||||
(void)cit;
|
(void)cit;
|
||||||
|
|
||||||
boostmap->erase(boostmap->begin()++);
|
boostmap->erase(boostmap->begin());
|
||||||
stdmap->erase(stdmap->begin()++);
|
stdmap->erase(stdmap->begin());
|
||||||
boostmultimap->erase(boostmultimap->begin()++);
|
boostmultimap->erase(boostmultimap->begin());
|
||||||
stdmultimap->erase(stdmultimap->begin()++);
|
stdmultimap->erase(stdmultimap->begin());
|
||||||
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
if(!CheckEqualPairContainers(boostmap, stdmap)) return 1;
|
||||||
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
if(!CheckEqualPairContainers(boostmultimap, stdmultimap)) return 1;
|
||||||
|
|
||||||
|
@@ -143,20 +143,20 @@ int set_test ()
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename MyBoostSet::iterator it;
|
typename MyBoostSet::iterator it = boostset->begin();
|
||||||
typename MyBoostSet::const_iterator cit = it;
|
typename MyBoostSet::const_iterator cit = it;
|
||||||
(void)cit;
|
(void)cit;
|
||||||
|
|
||||||
boostset->erase(boostset->begin()++);
|
boostset->erase(boostset->begin());
|
||||||
stdset->erase(stdset->begin()++);
|
stdset->erase(stdset->begin());
|
||||||
boostmultiset->erase(boostmultiset->begin()++);
|
boostmultiset->erase(boostmultiset->begin());
|
||||||
stdmultiset->erase(stdmultiset->begin()++);
|
stdmultiset->erase(stdmultiset->begin());
|
||||||
if(!CheckEqualContainers(boostset, stdset)){
|
if(!CheckEqualContainers(boostset, stdset)){
|
||||||
std::cout << "Error in boostset->erase(boostset->begin()++)" << std::endl;
|
std::cout << "Error in boostset->erase(boostset->begin())" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(!CheckEqualContainers(boostmultiset, stdmultiset)){
|
if(!CheckEqualContainers(boostmultiset, stdmultiset)){
|
||||||
std::cout << "Error in boostmultiset->erase(boostmultiset->begin()++)" << std::endl;
|
std::cout << "Error in boostmultiset->erase(boostmultiset->begin())" << std::endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,9 +41,13 @@ template class boost::container::vector<test::movable_and_copyable_int,
|
|||||||
|
|
||||||
namespace container_detail {
|
namespace container_detail {
|
||||||
|
|
||||||
|
#ifndef BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||||
|
|
||||||
template class vector_const_iterator<int*>;
|
template class vector_const_iterator<int*>;
|
||||||
template class vector_iterator<int*>;
|
template class vector_iterator<int*>;
|
||||||
|
|
||||||
|
#endif //BOOST_CONTAINER_VECTOR_ITERATOR_IS_POINTER
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}}
|
}}
|
||||||
|
Reference in New Issue
Block a user