This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] More noexcept for vectors


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]