<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 3158: tuple(allocator_arg_t, const Alloc&amp;) should be conditionally explicit</title>
<meta property="og:title" content="Issue 3158: tuple(allocator_arg_t, const Alloc&amp;) should be conditionally explicit">
<meta property="og:description" content="C++ library issue. Status: C++20">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue3158.html">
<meta property="og:type" content="website">
<meta property="og:image" content="http://cplusplus.github.io/LWG/images/cpp_logo.png">
<meta property="og:image:alt" content="C++ logo">
<style>
  p {text-align:justify}
  li {text-align:justify}
  pre code.backtick::before { content: "`" }
  pre code.backtick::after { content: "`" }
  blockquote.note
  {
    background-color:#E0E0E0;
    padding-left: 15px;
    padding-right: 15px;
    padding-top: 1px;
    padding-bottom: 1px;
  }
  ins {background-color:#A0FFA0}
  del {background-color:#FFA0A0}
  table.issues-index { border: 1px solid; border-collapse: collapse; }
  table.issues-index th { text-align: center; padding: 4px; border: 1px solid; }
  table.issues-index td { padding: 4px; border: 1px solid; }
  table.issues-index td:nth-child(1) { text-align: right; }
  table.issues-index td:nth-child(2) { text-align: left; }
  table.issues-index td:nth-child(3) { text-align: left; }
  table.issues-index td:nth-child(4) { text-align: left; }
  table.issues-index td:nth-child(5) { text-align: center; }
  table.issues-index td:nth-child(6) { text-align: center; }
  table.issues-index td:nth-child(7) { text-align: left; }
  table.issues-index td:nth-child(5) span.no-pr { color: red; }
  @media (prefers-color-scheme: dark) {
     html {
        color: #ddd;
        background-color: black;
     }
     ins {
        background-color: #225522
     }
     del {
        background-color: #662222
     }
     a {
        color: #6af
     }
     a:visited {
        color: #6af
     }
     blockquote.note
     {
        background-color: rgba(255, 255, 255, .10)
     }
  }
</style>
</head>
<body>
<hr>
<p><em>This page is a snapshot from the LWG issues list, see the <a href="lwg-active.html">Library Active Issues List</a> for more information and the meaning of <a href="lwg-active.html#C++20">C++20</a> status.</em></p>
<h3 id="3158"><a href="lwg-defects.html#3158">3158</a>. <code>tuple(allocator_arg_t, const Alloc&amp;)</code> should be conditionally explicit</h3>
<p><b>Section:</b> 22.4.4.2 <a href="https://wg21.link/tuple.cnstr">[tuple.cnstr]</a> <b>Status:</b> <a href="lwg-active.html#C++20">C++20</a>
 <b>Submitter:</b> Jonathan Wakely <b>Opened:</b> 2018-08-21 <b>Last modified:</b> 2021-02-25</p>
<p><b>Priority: </b>3
</p>
<p><b>View other</b> <a href="lwg-index-open.html#tuple.cnstr">active issues</a> in [tuple.cnstr].</p>
<p><b>View all other</b> <a href="lwg-index.html#tuple.cnstr">issues</a> in [tuple.cnstr].</p>
<p><b>View all issues with</b> <a href="lwg-status.html#C++20">C++20</a> status.</p>
<p><b>Discussion:</b></p>
<p>
<code>std::tuple</code>'s allocator-extended constructors say "<i>Effects:</i> Equivalent to the preceding constructors except 
that each element is constructed with uses-allocator construction". That's not true for the first one, as shown by:
</p>
<blockquote><pre>
#include &lt;tuple&gt;

struct X { explicit X() { } };

std::tuple&lt;X&gt; f() { return {}; }
std::tuple&lt;X&gt; g() { return { std::allocator_arg, std::allocator&lt;int&gt;{} }; }
</pre></blockquote>
<p>
The function <code>f()</code> doesn't compile because of the explicit constructor, but <code>g()</code> does, despite using the 
same constructor for <code>X</code>. The conditional explicit-ness is not equivalent.
<p/>
Also, the editor requested that we change "implicitly default-constructible" to use words that mean something. He suggested "copy-list-initializable from an empty list".
</p>

<p><i>[2018-09 Reflector prioritization]</i></p>

<p>Set Priority to 3</p>
<p><i>[2019-02; Kona Wednesday night issue processing]</i></p>

<p>Status to Ready</p>


<p id="res-3158"><b>Proposed resolution:</b></p>

<p>This wording is relative to <a href="https://wg21.link/n4762">N4762</a>.</p>

<ol>
<li><p>Modify 22.4.4 <a href="https://wg21.link/tuple.tuple">[tuple.tuple]</a>, class template <code>tuple</code> synopsis, as indicated:</p>
<blockquote><pre>
[&hellip;]
<i>// allocator-extended constructors</i>
template&lt;class Alloc&gt;
  <ins>explicit(<i>see below</i>)</ins> tuple(allocator_arg_t, const Alloc&amp; a);
template&lt;class Alloc&gt;
  explicit(<i>see below</i>) tuple(allocator_arg_t, const Alloc&amp; a, const Types&amp;...);
[&hellip;]
</pre></blockquote>
</li>

<li><p>Modify 22.4.4.2 <a href="https://wg21.link/tuple.cnstr">[tuple.cnstr]</a>, as indicated:</p>

<blockquote>
<pre>
explicit(<i>see below</i>) constexpr tuple();
</pre>
<blockquote>
<p>
-5- <i>Effects:</i> Value-initializes each element.
<p/>
-6- <i>Remarks:</i> This constructor shall not participate in overload resolution unless 
<code>is_default_constructible_v&lt;T<sub><i>i</i></sub>&gt;</code> is <code>true</code> for all 
<code><i>i</i></code>. [<i>Note:</i> This behavior can be implemented by a constructor template with default template 
arguments. &mdash; <i>end note</i>] The expression inside <code>explicit</code> evaluates to <code>true</code> if
and only if <code>T<sub><i>i</i></sub></code> is not <del>implicitly default-constructible</del>
<ins>copy-list-initializable from an empty list</ins> for at least one <code><i>i</i></code>. 
[<i>Note:</i> This behavior can be implemented with a trait that checks whether a 
<code>const T<sub><i>i</i></sub>&amp;</code> can be initialized with <code>{}</code>. &mdash; <i>end note</i>]
</p>
</blockquote>
<p>
[&hellip;]
</p>
<pre>
template&lt;class Alloc&gt;
  <ins>explicit(<i>see below</i>)</ins> tuple(allocator_arg_t, const Alloc&amp; a);
template&lt;class Alloc&gt;
  explicit(<i>see below</i>) tuple(allocator_arg_t, const Alloc&amp; a, const Types&amp;...);
[&hellip;]
template&lt;class Alloc, class U1, class U2&gt;
  explicit(<i>see below</i>) tuple(allocator_arg_t, const Alloc&amp; a, pair&lt;U1, U2&gt;&amp;&amp;);
</pre>
<blockquote>
<p>
-25- <i>Requires:</i> <code>Alloc</code> shall satisfy the <code><i>Cpp17Allocator</i></code> requirements (Table 33).
<p/>
[&hellip;]
</p>
</blockquote>
</blockquote>
</li>

</ol>





</body>
</html>
