|
| 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?> |
| 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd"> |
| 3 | + |
| 4 | +<issue num="4267" status="New"> |
| 5 | +<title>Uses-allocator construction is meaningless for tuple of references</title> |
| 6 | +<section><sref ref="[tuple.cnstr]"/></section> |
| 7 | +<submitter>Jiang An</submitter> |
| 8 | +<date>24 May 2025</date> |
| 9 | +<priority>99</priority> |
| 10 | + |
| 11 | +<discussion> |
| 12 | +<p> |
| 13 | +Per <sref ref="[allocator.uses.construction]"/>/1, uses-allocator construction is only defined for objects. |
| 14 | +And presumably, an attempt to construct `std::tuple` of reference from an `allocator_arg_t` constructor |
| 15 | +causes a hard error. |
| 16 | +<p/> |
| 17 | +Since C++23/<paper num="P2255R2"/>, it seems that these `allocator_arg_t` constructors are conditionally |
| 18 | +deleted according to <sref ref="[tuple.cnstr]"/>/33. However, it's confusing that these constructors are |
| 19 | +sometimes non-deleted when the tuple contains a reference, while there are hard errors in an instantiation |
| 20 | +instead. |
| 21 | +</p> |
| 22 | +</discussion> |
| 23 | + |
| 24 | +<resolution> |
| 25 | +<p> |
| 26 | +This wording is relative to <paper num="N5008"/>. |
| 27 | +</p> |
| 28 | +<ol> |
| 29 | + |
| 30 | +<li><p>Modify <sref ref="[tuple.cnstr]"/> as indicated:</p> |
| 31 | + |
| 32 | +<blockquote> |
| 33 | +<pre> |
| 34 | +template<class Alloc> |
| 35 | + constexpr explicit(<i>see below</i>) |
| 36 | + tuple(allocator_arg_t, const Alloc& a); |
| 37 | +[…] |
| 38 | +template<class Alloc, tuple-like UTuple> |
| 39 | + constexpr explicit(<i>see below</i>) |
| 40 | + tuple(allocator_arg_t, const Alloc& a, UTuple&&); |
| 41 | +</pre> |
| 42 | +<blockquote> |
| 43 | +<p> |
| 44 | +-32- <i>Preconditions</i>: `Alloc` meets the <i>Cpp17Allocator</i> requirements (<sref ref="[allocator.requirements.general]"/>). |
| 45 | +<p/> |
| 46 | +-33- <i>Effects</i>: Equivalent to the preceding constructors except that each element is constructed with uses-allocator |
| 47 | +construction (<sref ref="[allocator.uses.construction]"/>). |
| 48 | +<p/> |
| 49 | +<ins>-?- <i>Remarks</i>: These constructors are defined as deleted if <tt>is_reference_v<T<sub><i>i</i></sub>></tt> |
| 50 | +is `true` for at least one <tt>T<sub><i>i</i></sub></tt>.</ins> |
| 51 | +</p> |
| 52 | +</blockquote> |
| 53 | +</blockquote> |
| 54 | + |
| 55 | +</li> |
| 56 | + |
| 57 | +</ol> |
| 58 | + |
| 59 | +</resolution> |
| 60 | + |
| 61 | +</issue> |
0 commit comments