This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [v3] More noexcept for vectors
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: "libstdc++" <libstdc++ at gcc dot gnu dot org>
- Cc: Paolo Carlini <paolo dot carlini at oracle dot com>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 16 Sep 2013 13:20:18 +0100
- Subject: Re: [v3] More noexcept for vectors
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1309141228580 dot 9493 at stedding dot saclay dot inria dot fr> <770d7b77-69e8-48ea-a7d4-5a6ca499cf83 at email dot android dot com> <a7b55575-dc1a-4015-8a4c-fc8adcfc941f at email dot android dot com> <alpine dot DEB dot 2 dot 10 dot 1309141716050 dot 10149 at laptop-mg dot saclay dot inria dot fr> <23d2470b-21ca-42fe-8bd1-e95a370f2d65 at email dot android dot com> <alpine dot DEB dot 2 dot 02 dot 1309151042420 dot 30089 at stedding dot saclay dot inria dot fr>
On 15 September 2013 10:12, Marc Glisse wrote:
>
> PR libstdc++/58338
> * include/bits/stl_vector.h
> (_Vector_impl::_Vector_impl(_Tp_alloc_type const&),
> _Vector_impl::_Vector_impl(_Tp_alloc_type&&),
> _Vector_impl::_M_swap_data,
> _Vector_base::_Vector_base(const allocator_type&),
> _Vector_base::_Vector_base(allocator_type&&),
> _Vector_base::_Vector_base(_Vector_base&&),
> vector::vector(const allocator_type&), vector::operator[],
> vector::operator[] const, vector::front, vector::front const,
> vector::back, vector::back const, vector::pop_back,
> vector::_M_erase_at_end): Mark as noexcept.
> (vector::~vector): Remove useless noexcept.
Are you sure the noexcept on the destructors is useless?
A user-defined allocator type could have
is_nothrow_descructible<allocator_type>::value==false or
is_nothrow_destructible<pointer>::value==false, which would alter the
type of is_nothrow_destructible<vector<T, A>>.
Although the user-defined allocator must not actually throw from its
destructor, it is not required to have a noexcept destructor.
However, since it must not actually throw (irrespective of its
exception spec) we can unconditionally give std::vector a noexcept
destructor.