Skip to content

Suggestion: investigate noexcept specification for allocator_traits::deallocate/destroy #5593

Description

@achabense

A lot of clear-related functions rely on allocator_traits::destroy/deallocate, and are marked as noexcept (either required by standard or strengethened). Examples are many and are not listed here (search ::deallocate and ::destroy in the library).

However:
allocator_traits is either _Default_allocator_traits or _Normal_allocator_traits.

STL/stl/inc/xmemory

Lines 759 to 760 in 313964b

struct allocator_traits : conditional_t<_Is_default_allocator<_Alloc>::value, _Default_allocator_traits<_Alloc>,
_Normal_allocator_traits<_Alloc>> {};

But currently:
_Default_allocator_traits: deallocate is marked as noexcept; but destroy is not.
deallocate: made noexcept by #4977

static _CONSTEXPR20 void deallocate(_Alloc& _Al, const pointer _Ptr, const size_type _Count) noexcept

destroy: not noexcept.
static _CONSTEXPR20 void destroy(_Alloc&, _Uty* const _Ptr) {

_Normal_allocator_traits: neither deallocate nor destroy are noexcept.
deallocate:

static _CONSTEXPR20 void deallocate(_Alloc& _Al, pointer _Ptr, size_type _Count) {

destroy:
static _CONSTEXPR20 void destroy(_Alloc& _Al, _Ty* _Ptr) {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSomething can be improved

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions