Subject: Re: [Boost-bugs] [Boost C++ Libraries] #6575: copy_remaining_to and copy_some_and_update don't use allocator_traits for construction
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-02-19 15:59:38
#6575: copy_remaining_to and copy_some_and_update don't use allocator_traits for
construction
-------------------------------------------------+--------------------------
Reporter: Erik Jensen <Erik.Jensen@â¦> | Owner: igaztanaga
Type: Bugs | Status: new
Milestone: To Be Determined | Component: container
Version: Boost 1.49.0 | Severity: Problem
Resolution: | Keywords:
-------------------------------------------------+--------------------------
Comment (by igaztanaga):
Both libc++ (clang) and libstdc++ (g++) implement the same approach as
Boost.Container. The inserted element gets the container allocator as it
is moved to an existing object built with with allocator_traits. I think
the issue is not clear, and only happens in vector and deque (node-based
containers allocates some memory and build the object directly there).
Instead of aligned storage, or a temporary, which might use some undefined
stack space (we don't know how big T is), another alternative is to
reserve additional capacity for two new elements at the end of the
vector/deque before emplacing (instead of just one, it's really a
negligible cost, as the vector capacity grows exponentially). Then built
the object with allocator_traits in the end() + 1 position (with a
rollback operation to destroy the element at the end of the scope, as it
should be destroyed anyway after being moved to the right position).
This is not simple to do in Boost.Container as all [uninitialized]copy
operations are hidden behind an abstract interface to avoid instantiating
insertion bookeeing functions for each iterator type, but maybe we need
some interface extension.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/6575#comment:4> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC