[v3] More noexcept for vectors
Jonathan Wakely
jwakely.gcc@gmail.com
Mon Sep 16 12:20:00 GMT 2013
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.
More information about the Libstdc++
mailing list