Issue 4312: Const and value category mismatch for allocator_arg_t/allocator_arg in the description
of uses-allocator construction (original) (raw)
This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of WP status.
4312. Const and value category mismatch for allocator_arg_t/allocator_arg in the description of uses-allocator construction
Section: 20.2.8.2 [allocator.uses.construction] Status: WP Submitter: Jiang An Opened: 2025-08-06 Last modified: 2025-11-11
Priority: Not Prioritized
View all other issues in [allocator.uses.construction].
View all issues with WP status.
Discussion:
Currently, 20.2.8.2 [allocator.uses.construction] bullet 2.2 states:
Otherwise, if
Thas a constructor invocable asT(allocator_arg, alloc, args...)(leading-allocator convention), […]
However, when forming construction arguments in the utility functions, we're actually using _cv_-unqualified rvalue of allocator_arg_t, which can be inferred from using plain allocator_arg_t but not const allocator_arg_t& in 20.2.8.2 [allocator.uses.construction] bullet 5.2.
It seems that such mismatch was present even since C++11 (per N3337 [allocator.uses.construction]/1.2). If the use of plain allocator_arg_t is considered correct, I think we should fix the description.
[2025-10-14; Reflector poll]
Set status to Tentatively Ready after five votes in favour during reflector poll.
Unless the std::allocator_arg tag object is not supposed to be used, wouldn't it make more sense to preserve the "if T has a constructor invocable as T(allocator_arg, alloc, args...)" wording and change every allocator_arg_t intoconst allocator_arg_t&, so that we check for construction from the const tag object, and then actually use a const value in the constructor arguments. Strongly don't care though.
[Kona 2025-11-08; Status changed: Voting → WP.]
Proposed resolution:
This wording is relative to N5014.
- Modify 20.2.8.2 [allocator.uses.construction] as indicated:
-2- The following utility functions support three conventions for passing
allocto a constructor:- (2.1) — […]
- (2.2) — Otherwise, if
Thas a constructor invocable asT(~~allocator_arg~~allocator_arg_t{}, alloc, args...)(leading-allocator convention), then uses-allocator construction chooses this constructor form. - (2.3) — […]