This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
Section: 22.4.4.2 [tuple.cnstr] Status: New Submitter: Jiang An Opened: 2025-05-24 Last modified: 2025-10-17
Priority: 3
View other active issues in [tuple.cnstr].
View all other issues in [tuple.cnstr].
View all issues with New status.
Discussion:
Per 20.2.8.2 [allocator.uses.construction]/1, uses-allocator construction is only defined for objects.
And presumably, an attempt to construct std::tuple of reference from an allocator_arg_t constructor
causes a hard error.
allocator_arg_t constructors are conditionally
deleted according to 22.4.4.2 [tuple.cnstr]/33. However, it's confusing that these constructors are
sometimes non-deleted when the tuple contains a reference, while there are hard errors in an instantiation
instead.
[2025-10-14; Reflector poll]
Set priority to 3 after reflector poll.
"There is a defect, but the right fix is to just define uses-allocator construction of references as equivalent to normal construction."
Previous resolution [SUPERSEDED]:
This wording is relative to N5008.
Modify 22.4.4.2 [tuple.cnstr] as indicated:
template<class Alloc> constexpr explicit(see below) tuple(allocator_arg_t, const Alloc& a); […] template<class Alloc, tuple-like UTuple> constexpr explicit(see below) tuple(allocator_arg_t, const Alloc& a, UTuple&&);-32- Preconditions:
-33- Effects: Equivalent to the preceding constructors except that each element is constructed with uses-allocator construction (20.2.8.2 [allocator.uses.construction]). -?- Remarks: These constructors are defined as deleted ifAllocmeets the Cpp17Allocator requirements (16.4.4.6.1 [allocator.requirements.general]).is_reference_v<Ti>istruefor at least oneTi.
[2025-10-15; Jonathan provides new wording]
I don't think we care about uses-allocator construction of references in general.
You can't construct a reference using allocator_traits::construct nor put references in containers.
For a std::pair containing a reference, I think make_obj_using_allocator and uses_allocator_construction_args work fine.
The problem only exists in the std::tuple wording where we say that the elements are constructed using uses-allocator construction.
So let's just fix that.
Proposed resolution:
This wording is relative to N5014.
Modify 22.4.4.2 [tuple.cnstr] as indicated:
template<class Alloc> constexpr explicit(see below) tuple(allocator_arg_t, const Alloc& a); […] template<class Alloc, tuple-like UTuple> constexpr explicit(see below) tuple(allocator_arg_t, const Alloc& a, UTuple&&);-32- Preconditions:
-33- Effects: Equivalent to the preceding constructors except that each element of non-reference type is constructed with uses-allocator construction (20.2.8.2 [allocator.uses.construction]).Allocmeets the Cpp17Allocator requirements (16.4.4.6.1 [allocator.requirements.general]).