Title
Uses-allocator construction is meaningless for tuple of references
Status
new
Section
[tuple.cnstr]
Submitter
Jiang An

Created on 2025-05-24.00:00:00 last changed 6 days ago

Messages

Date: 2025-05-24.10:55:43

Proposed resolution:

This wording is relative to N5008.

  1. Modify [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 ([allocator.requirements.general]).

    -33- Effects: Equivalent to the preceding constructors except that each element is constructed with uses-allocator construction ([allocator.uses.construction]).

    -?- Remarks: These constructors are defined as deleted if is_reference_v<Ti> is `true` for at least one Ti.

Date: 2025-05-24.00:00:00

Per [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 [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.

History
Date User Action Args
2025-05-24 10:55:43adminsetmessages: + msg14770
2025-05-24 00:00:00admincreate