This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

3116. OUTERMOST_ALLOC_TRAITS needs remove_reference_t

Section: 20.5.4 [allocator.adaptor.members] Status: C++20 Submitter: Tim Song Opened: 2018-06-04 Last modified: 2021-02-25

Priority: 0

View all other issues in [allocator.adaptor.members].

View all issues with C++20 status.


OUTERMOST_ALLOC_TRAITS(x) is currently defined in 20.5.4 [allocator.adaptor.members]p1 as allocator_traits<decltype(OUTERMOST(x))>. However, OUTERMOST(x), as defined and used in this subclause, is an lvalue for which decltype produces an lvalue reference. That referenceness needs to be removed before the type can be used with allocator_traits.

While we are here, the current wording for OUTERMOST uses the imprecise "if x does not have an outer_allocator() member function". What we meant to check is the validity of the expression x.outer_allocator(), not whether x has some (possibly ambiguous and/or inaccessible) member function named outer_allocator.

[2018-06 Rapperswil Thursday issues processing]

Status to Ready

[2018-11, Adopted in San Diego]

Proposed resolution:

This wording is relative to N4750.

[Drafting note: The subclause only uses OUTERMOST_ALLOC_TRAITS(*this) and only in non-const member functions, so the result is also non-const. Thus, remove_reference_t is sufficient; there's no need to further remove cv-qualification. — end drafting note]

  1. Modify 20.5.4 [allocator.adaptor.members]p1 as indicated:

    -1- In the construct member functions, OUTERMOST(x) is x if x does not have an outer_allocator() member function and OUTERMOST(x.outer_allocator()) if the expression x.outer_allocator() is valid (13.10.3 [temp.deduct]) and x otherwise; OUTERMOST_ALLOC_TRAITS(x) is allocator_traits<remove_reference_t<decltype(OUTERMOST(x))>>. [Note: […] — end note]