|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82889 - trunk/boost/container/detail
From: igaztanaga_at_[hidden]
Date: 2013-02-14 14:43:13
Author: igaztanaga
Date: 2013-02-14 14:43:13 EST (Thu, 14 Feb 2013)
New Revision: 82889
URL: http://svn.boost.org/trac/boost/changeset/82889
Log:
Added uninitialized_default_alloc as current code didn't use allocator_traits
Text files modified:
trunk/boost/container/detail/advanced_insert_int.hpp | 35 +++--------
trunk/boost/container/detail/utilities.hpp | 115 ++++++++++++++++++++++++++++++++-------
2 files changed, 103 insertions(+), 47 deletions(-)
Modified: trunk/boost/container/detail/advanced_insert_int.hpp
==============================================================================
--- trunk/boost/container/detail/advanced_insert_int.hpp (original)
+++ trunk/boost/container/detail/advanced_insert_int.hpp 2013-02-14 14:43:13 EST (Thu, 14 Feb 2013)
@@ -37,15 +37,15 @@
: 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->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_;
@@ -63,15 +63,15 @@
: 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->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_;
@@ -90,7 +90,7 @@
{}
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)
{ std::fill_n(p, n, v_); }
@@ -112,22 +112,7 @@
{}
void uninitialized_copy_n_and_update(Iterator p, size_type n)
- {
- 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
- }
+ { boost::container::uninitialized_default_alloc_n(this->a_, n, p); }
void copy_n_and_update(Iterator, size_type)
{
Modified: trunk/boost/container/detail/utilities.hpp
==============================================================================
--- trunk/boost/container/detail/utilities.hpp (original)
+++ trunk/boost/container/detail/utilities.hpp 2013-02-14 14:43:13 EST (Thu, 14 Feb 2013)
@@ -136,11 +136,11 @@
//! <b>Effects</b>:
//! \code
-//! for (; first != last; ++result, ++first)
-//! allocator_traits::construct(a, &*result, boost::move(*first));
+//! for (; f != l; ++r, ++f)
+//! allocator_traits::construct(a, &*r, boost::move(*f));
//! \endcode
//!
-//! <b>Returns</b>: result
+//! <b>Returns</b>: r
template
<typename A,
typename I, // I models InputIterator
@@ -172,11 +172,11 @@
//! <b>Effects</b>:
//! \code
-//! for (; n--; ++result, ++first)
-//! allocator_traits::construct(a, &*result, boost::move(*first));
+//! for (; n--; ++r, ++f)
+//! allocator_traits::construct(a, &*r, boost::move(*f));
//! \endcode
//!
-//! <b>Returns</b>: result
+//! <b>Returns</b>: r
template
<typename A,
typename I, // I models InputIterator
@@ -208,11 +208,11 @@
//! <b>Effects</b>:
//! \code
-//! for (; n--; ++result, ++first)
-//! allocator_traits::construct(a, &*result, boost::move(*first));
+//! for (; n--; ++r, ++f)
+//! allocator_traits::construct(a, &*r, boost::move(*f));
//! \endcode
//!
-//! <b>Returns</b>: first (after incremented)
+//! <b>Returns</b>: f (after incremented)
template
<typename A,
typename I, // I models InputIterator
@@ -244,11 +244,11 @@
//! <b>Effects</b>:
//! \code
-//! for (; first != last; ++result, ++first)
-//! allocator_traits::construct(a, &*result, *first);
+//! for (; f != l; ++r, ++f)
+//! allocator_traits::construct(a, &*r, *f);
//! \endcode
//!
-//! <b>Returns</b>: result
+//! <b>Returns</b>: r
template
<typename A,
typename I, // I models InputIterator
@@ -280,11 +280,11 @@
//! <b>Effects</b>:
//! \code
-//! for (; n--; ++result, ++first)
-//! allocator_traits::construct(a, &*result, *first);
+//! for (; n--; ++r, ++f)
+//! allocator_traits::construct(a, &*r, *f);
//! \endcode
//!
-//! <b>Returns</b>: result
+//! <b>Returns</b>: r
template
<typename A,
typename I, // I models InputIterator
@@ -316,11 +316,11 @@
//! <b>Effects</b>:
//! \code
-//! for (; n--; ++result, ++first)
-//! allocator_traits::construct(a, &*result, *first);
+//! for (; n--; ++r, ++f)
+//! allocator_traits::construct(a, &*r, *f);
//! \endcode
//!
-//! <b>Returns</b>: first (after incremented)
+//! <b>Returns</b>: f (after incremented)
template
<typename A,
typename I, // I models InputIterator
@@ -352,11 +352,11 @@
//! <b>Effects</b>:
//! \code
-//! for (; first != last; ++result, ++first)
-//! allocator_traits::construct(a, &*result, *first);
+//! for (; f != l; ++r, ++f)
+//! allocator_traits::construct(a, &*r, *f);
//! \endcode
//!
-//! <b>Returns</b>: result
+//! <b>Returns</b>: r
template
<typename A,
typename F, // F models ForwardIterator
@@ -472,6 +472,78 @@
//////////////////////////////////////////////////////////////////////////////
//
+// 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
//
//////////////////////////////////////////////////////////////////////////////
@@ -631,7 +703,6 @@
} //namespace container {
} //namespace boost {
-
#include <boost/container/detail/config_end.hpp>
#endif //#ifndef BOOST_CONTAINER_DETAIL_UTILITIES_HPP
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk