This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/64865] std::allocator::construct/destroy not called for specialization of std::allocator<trivialtype>
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 30 Jan 2015 11:05:52 +0000
- Subject: [Bug libstdc++/64865] std::allocator::construct/destroy not called for specialization of std::allocator<trivialtype>
- Auto-submitted: auto-generated
- References: <bug-64865-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64865
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to TC from comment #2)
> Since the allocator_type member must be the Alloc template argument provided
> by the user and not any rebound types, though,
N.B. libstdc++ supports std::vector<int, std::allocator<char>> and so always
rebinds the _Alloc parameter to get an allocator for the value_type. That
doesn't change your argument though, because it will rebind it to
allocator<value_type> and that's the type that's specialized.
> it seems to me that it is in
> fact guaranteed that their versions of construct() and destroy() will be
> called, as the paragraph you cite requires the use of
> allocator_traits<allocator_type>::construct and
> allocator_traits<allocator_type>::destroy.
That's a defect, see http://cplusplus.github.io/LWG/lwg-active.html#2218
That defect is a problem for node-based containers, but in principle any
container should be able to use
allocator_traits<allocator_type>::rebind_traits<SomeInternalType>::construct()
to construct the elements, in which case your allocator<value_type>
specialization is not used.