mirror of
https://github.com/boostorg/container.git
synced 2025-08-03 14:34:27 +02:00
Added uninitialized_default_alloc as current code didn't use allocator_traits
[SVN r82889]
This commit is contained in:
@@ -37,15 +37,15 @@ struct move_insert_range_proxy
|
|||||||
: a_(a), first_(first)
|
: a_(a), first_(first)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void uninitialized_copy_n_and_update(Iterator pos, size_type n)
|
void uninitialized_copy_n_and_update(Iterator p, size_type n)
|
||||||
{
|
{
|
||||||
this->first_ = ::boost::container::uninitialized_move_alloc_n_source
|
this->first_ = ::boost::container::uninitialized_move_alloc_n_source
|
||||||
(this->a_, this->first_, n, pos);
|
(this->a_, this->first_, n, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_n_and_update(Iterator pos, size_type n)
|
void copy_n_and_update(Iterator p, size_type n)
|
||||||
{
|
{
|
||||||
this->first_ = ::boost::container::move_n_source(this->first_, n, pos);
|
this->first_ = ::boost::container::move_n_source(this->first_, n, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
A &a_;
|
A &a_;
|
||||||
@@ -63,15 +63,15 @@ struct insert_range_proxy
|
|||||||
: a_(a), first_(first)
|
: a_(a), first_(first)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void uninitialized_copy_n_and_update(Iterator pos, size_type n)
|
void uninitialized_copy_n_and_update(Iterator p, size_type n)
|
||||||
{
|
{
|
||||||
this->first_ = ::boost::container::uninitialized_copy_or_move_alloc_n_source
|
this->first_ = ::boost::container::uninitialized_copy_or_move_alloc_n_source
|
||||||
(this->a_, this->first_, n, pos);
|
(this->a_, this->first_, n, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
void copy_n_and_update(Iterator pos, size_type n)
|
void copy_n_and_update(Iterator p, size_type n)
|
||||||
{
|
{
|
||||||
this->first_ = ::boost::container::copy_or_move_n_source(this->first_, n, pos);
|
this->first_ = ::boost::container::copy_or_move_n_source(this->first_, n, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
A &a_;
|
A &a_;
|
||||||
@@ -90,7 +90,7 @@ struct insert_n_copies_proxy
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
void uninitialized_copy_n_and_update(Iterator p, size_type n)
|
void uninitialized_copy_n_and_update(Iterator p, size_type n)
|
||||||
{ std::uninitialized_fill_n(p, n, v_); }
|
{ boost::container::uninitialized_fill_alloc_n(this->a_, v_, n, p); }
|
||||||
|
|
||||||
void copy_n_and_update(Iterator p, size_type n)
|
void copy_n_and_update(Iterator p, size_type n)
|
||||||
{ std::fill_n(p, n, v_); }
|
{ std::fill_n(p, n, v_); }
|
||||||
@@ -112,22 +112,7 @@ struct insert_default_constructed_n_proxy
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
void uninitialized_copy_n_and_update(Iterator p, size_type n)
|
void uninitialized_copy_n_and_update(Iterator p, size_type n)
|
||||||
{
|
{ boost::container::uninitialized_default_alloc_n(this->a_, n, p); }
|
||||||
Iterator orig_p = p;
|
|
||||||
size_type n_left = n;
|
|
||||||
BOOST_TRY{
|
|
||||||
for(; n_left--; ++p){
|
|
||||||
alloc_traits::construct(this->a_, container_detail::to_raw_pointer(&*p));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BOOST_CATCH(...){
|
|
||||||
for(; orig_p != p; ++orig_p){
|
|
||||||
alloc_traits::destroy(this->a_, container_detail::to_raw_pointer(&*orig_p++));
|
|
||||||
}
|
|
||||||
BOOST_RETHROW
|
|
||||||
}
|
|
||||||
BOOST_CATCH_END
|
|
||||||
}
|
|
||||||
|
|
||||||
void copy_n_and_update(Iterator, size_type)
|
void copy_n_and_update(Iterator, size_type)
|
||||||
{
|
{
|
||||||
|
@@ -136,11 +136,11 @@ struct ct_rounded_size
|
|||||||
|
|
||||||
//! <b>Effects</b>:
|
//! <b>Effects</b>:
|
||||||
//! \code
|
//! \code
|
||||||
//! for (; first != last; ++result, ++first)
|
//! for (; f != l; ++r, ++f)
|
||||||
//! allocator_traits::construct(a, &*result, boost::move(*first));
|
//! allocator_traits::construct(a, &*r, boost::move(*f));
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//!
|
//!
|
||||||
//! <b>Returns</b>: result
|
//! <b>Returns</b>: r
|
||||||
template
|
template
|
||||||
<typename A,
|
<typename A,
|
||||||
typename I, // I models InputIterator
|
typename I, // I models InputIterator
|
||||||
@@ -172,11 +172,11 @@ F uninitialized_move_alloc(A &a, I f, I l, F r)
|
|||||||
|
|
||||||
//! <b>Effects</b>:
|
//! <b>Effects</b>:
|
||||||
//! \code
|
//! \code
|
||||||
//! for (; n--; ++result, ++first)
|
//! for (; n--; ++r, ++f)
|
||||||
//! allocator_traits::construct(a, &*result, boost::move(*first));
|
//! allocator_traits::construct(a, &*r, boost::move(*f));
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//!
|
//!
|
||||||
//! <b>Returns</b>: result
|
//! <b>Returns</b>: r
|
||||||
template
|
template
|
||||||
<typename A,
|
<typename A,
|
||||||
typename I, // I models InputIterator
|
typename I, // I models InputIterator
|
||||||
@@ -208,11 +208,11 @@ F uninitialized_move_alloc_n(A &a, I f, typename std::iterator_traits<I>::differ
|
|||||||
|
|
||||||
//! <b>Effects</b>:
|
//! <b>Effects</b>:
|
||||||
//! \code
|
//! \code
|
||||||
//! for (; n--; ++result, ++first)
|
//! for (; n--; ++r, ++f)
|
||||||
//! allocator_traits::construct(a, &*result, boost::move(*first));
|
//! allocator_traits::construct(a, &*r, boost::move(*f));
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//!
|
//!
|
||||||
//! <b>Returns</b>: first (after incremented)
|
//! <b>Returns</b>: f (after incremented)
|
||||||
template
|
template
|
||||||
<typename A,
|
<typename A,
|
||||||
typename I, // I models InputIterator
|
typename I, // I models InputIterator
|
||||||
@@ -244,11 +244,11 @@ I uninitialized_move_alloc_n_source(A &a, I f, typename std::iterator_traits<I>:
|
|||||||
|
|
||||||
//! <b>Effects</b>:
|
//! <b>Effects</b>:
|
||||||
//! \code
|
//! \code
|
||||||
//! for (; first != last; ++result, ++first)
|
//! for (; f != l; ++r, ++f)
|
||||||
//! allocator_traits::construct(a, &*result, *first);
|
//! allocator_traits::construct(a, &*r, *f);
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//!
|
//!
|
||||||
//! <b>Returns</b>: result
|
//! <b>Returns</b>: r
|
||||||
template
|
template
|
||||||
<typename A,
|
<typename A,
|
||||||
typename I, // I models InputIterator
|
typename I, // I models InputIterator
|
||||||
@@ -280,11 +280,11 @@ F uninitialized_copy_alloc(A &a, I f, I l, F r)
|
|||||||
|
|
||||||
//! <b>Effects</b>:
|
//! <b>Effects</b>:
|
||||||
//! \code
|
//! \code
|
||||||
//! for (; n--; ++result, ++first)
|
//! for (; n--; ++r, ++f)
|
||||||
//! allocator_traits::construct(a, &*result, *first);
|
//! allocator_traits::construct(a, &*r, *f);
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//!
|
//!
|
||||||
//! <b>Returns</b>: result
|
//! <b>Returns</b>: r
|
||||||
template
|
template
|
||||||
<typename A,
|
<typename A,
|
||||||
typename I, // I models InputIterator
|
typename I, // I models InputIterator
|
||||||
@@ -316,11 +316,11 @@ F uninitialized_copy_alloc_n(A &a, I f, typename std::iterator_traits<I>::differ
|
|||||||
|
|
||||||
//! <b>Effects</b>:
|
//! <b>Effects</b>:
|
||||||
//! \code
|
//! \code
|
||||||
//! for (; n--; ++result, ++first)
|
//! for (; n--; ++r, ++f)
|
||||||
//! allocator_traits::construct(a, &*result, *first);
|
//! allocator_traits::construct(a, &*r, *f);
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//!
|
//!
|
||||||
//! <b>Returns</b>: first (after incremented)
|
//! <b>Returns</b>: f (after incremented)
|
||||||
template
|
template
|
||||||
<typename A,
|
<typename A,
|
||||||
typename I, // I models InputIterator
|
typename I, // I models InputIterator
|
||||||
@@ -352,11 +352,11 @@ I uninitialized_copy_alloc_n_source(A &a, I f, typename std::iterator_traits<I>:
|
|||||||
|
|
||||||
//! <b>Effects</b>:
|
//! <b>Effects</b>:
|
||||||
//! \code
|
//! \code
|
||||||
//! for (; first != last; ++result, ++first)
|
//! for (; f != l; ++r, ++f)
|
||||||
//! allocator_traits::construct(a, &*result, *first);
|
//! allocator_traits::construct(a, &*r, *f);
|
||||||
//! \endcode
|
//! \endcode
|
||||||
//!
|
//!
|
||||||
//! <b>Returns</b>: result
|
//! <b>Returns</b>: r
|
||||||
template
|
template
|
||||||
<typename A,
|
<typename A,
|
||||||
typename F, // F models ForwardIterator
|
typename F, // F models ForwardIterator
|
||||||
@@ -470,6 +470,78 @@ I uninitialized_copy_or_move_alloc_n_source
|
|||||||
return ::boost::container::uninitialized_copy_alloc_n_source(a, f, n, r);
|
return ::boost::container::uninitialized_copy_alloc_n_source(a, f, n, r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// uninitialized_default_alloc_n
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//! <b>Effects</b>:
|
||||||
|
//! \code
|
||||||
|
//! for (; n--; ++r, ++f)
|
||||||
|
//! allocator_traits::construct(a, &*r);
|
||||||
|
//! \endcode
|
||||||
|
//!
|
||||||
|
//! <b>Returns</b>: r
|
||||||
|
template
|
||||||
|
<typename A,
|
||||||
|
typename F> // F models ForwardIterator
|
||||||
|
F uninitialized_default_alloc_n(A &a, typename allocator_traits<A>::difference_type n, F r)
|
||||||
|
{
|
||||||
|
F back = r;
|
||||||
|
BOOST_TRY{
|
||||||
|
while (n--) {
|
||||||
|
allocator_traits<A>::construct(a, container_detail::to_raw_pointer(&*r));
|
||||||
|
++r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BOOST_CATCH(...){
|
||||||
|
for (; back != r; ++back){
|
||||||
|
allocator_traits<A>::destroy(a, container_detail::to_raw_pointer(&*back));
|
||||||
|
}
|
||||||
|
BOOST_RETHROW;
|
||||||
|
}
|
||||||
|
BOOST_CATCH_END
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// uninitialized_fill_alloc_n
|
||||||
|
//
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
//! <b>Effects</b>:
|
||||||
|
//! \code
|
||||||
|
//! for (; n--; ++r, ++f)
|
||||||
|
//! allocator_traits::construct(a, &*r, v);
|
||||||
|
//! \endcode
|
||||||
|
//!
|
||||||
|
//! <b>Returns</b>: r
|
||||||
|
template
|
||||||
|
<typename A,
|
||||||
|
typename T,
|
||||||
|
typename F> // F models ForwardIterator
|
||||||
|
F uninitialized_fill_alloc_n(A &a, const T &v, typename allocator_traits<A>::difference_type n, F r)
|
||||||
|
{
|
||||||
|
F back = r;
|
||||||
|
BOOST_TRY{
|
||||||
|
while (n--) {
|
||||||
|
allocator_traits<A>::construct(a, container_detail::to_raw_pointer(&*r), v);
|
||||||
|
++r;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BOOST_CATCH(...){
|
||||||
|
for (; back != r; ++back){
|
||||||
|
allocator_traits<A>::destroy(a, container_detail::to_raw_pointer(&*back));
|
||||||
|
}
|
||||||
|
BOOST_RETHROW;
|
||||||
|
}
|
||||||
|
BOOST_CATCH_END
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
// copy_or_move
|
// copy_or_move
|
||||||
@@ -631,7 +703,6 @@ inline I move_n_source(I f, typename std::iterator_traits<I>::difference_type n,
|
|||||||
} //namespace container {
|
} //namespace container {
|
||||||
} //namespace boost {
|
} //namespace boost {
|
||||||
|
|
||||||
|
|
||||||
#include <boost/container/detail/config_end.hpp>
|
#include <boost/container/detail/config_end.hpp>
|
||||||
|
|
||||||
#endif //#ifndef BOOST_CONTAINER_DETAIL_UTILITIES_HPP
|
#endif //#ifndef BOOST_CONTAINER_DETAIL_UTILITIES_HPP
|
||||||
|
Reference in New Issue
Block a user