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.

4267. Uses-allocator construction is meaningless for tuple of references

Section: 22.4.4.2 [tuple.cnstr] Status: New Submitter: Jiang An Opened: 2025-05-24 Last modified: 2025-05-24

Priority: Not Prioritized

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.

Since C++23/P2255R2, it seems that these 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.

Proposed resolution:

This wording is relative to N5008.

  1. 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: Alloc meets the Cpp17Allocator requirements (16.4.4.6.1 [allocator.requirements.general]).

    -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 if is_reference_v<Ti> is true for at least one Ti.