<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Issue 2419: Clang's libc++ extension to std::tuple</title>
<meta property="og:title" content="Issue 2419: Clang's libc++ extension to std::tuple">
<meta property="og:description" content="C++ library issue. Status: Resolved">
<meta property="og:url" content="https://cplusplus.github.io/LWG/issue2419.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#Resolved">Resolved</a> status.</em></p>
<h3 id="2419"><a href="lwg-defects.html#2419">2419</a>. Clang's libc++ extension to <code>std::tuple</code></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#Resolved">Resolved</a>
 <b>Submitter:</b> Akim Demaille <b>Opened:</b> 2014-07-11 <b>Last modified:</b> 2018-06-23</p>
<p><b>Priority: </b>Not Prioritized
</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#Resolved">Resolved</a> status.</p>
<p><b>Discussion:</b></p>
<p>
The issue has been submitted after exchanges with the clang++ team
as a consequence of two PR I sent:
<p/>
<a href="http://llvm.org/bugs/show_bug.cgi?id=20174">Issue 20174</a>
<p/>
<a href="http://llvm.org/bugs/show_bug.cgi?id=20175">Issue 20175</a>
<p/>
The short version is shown in the program below:
</p>
<blockquote>
<pre>
#include &lt;iostream&gt;
#include &lt;tuple&gt;

struct base
{
  void out(const std::tuple&lt;char, char&gt;&amp; w) const
  {
    std::cerr &lt;&lt; "Tuple: " &lt;&lt; std::get&lt;0&gt;(w) &lt;&lt; std::get&lt;1&gt;(w) &lt;&lt; '\n';
  }
};

struct decorator
{
  base b_;

  template &lt;typename... Args&gt;
  auto
  out(Args&amp;&amp;... args)
    -> decltype(b_.out(args...))
  {
    return b_.out(args...);
  }

  void out(const char&amp; w)
  {
    std::cerr &lt;&lt; "char: " &lt;&lt; w &lt;&lt; '\n';
  }
};

int main()
{
  decorator d{base{}};
  char l = 'a';
  d.out(l);
}
</pre>
</blockquote>
<p>
This is a stripped down version of a real world case where I
wrap objects in decorators.  These decorators contributes some
functions, and forward all the rest of the API to the wrapped
object using perfect forwarding.  There can be overloaded names.
<p/>
Here the inner object provides an
</p>
<blockquote><pre>
out(const std::tuple&lt;char, char&gt;&amp;) -&gt; void
</pre></blockquote>
<p>
function, and the wrappers, in addition to perfect forwarding,
provides
</p>
<blockquote><pre>
out(const char&amp;) -&gt; void
</pre></blockquote>
<p>
The main function then call <code>out(l)</code> where <code>l</code> is a <code>char</code> lvalue.
<p/>
With (GCC's) libstdc++ I get the expected result: the <code>char</code>
overload is run.  With (clang++'s) libc++ it is the tuple
version which is run.
</p>
<blockquote><pre>
$ g++-mp-4.9 -std=c++11 bar.cc &amp;&amp; ./a.out
char: a
$ clang++-mp-3.5 -std=c++11 bar.cc -Wall &amp;&amp; ./a.out
Tuple: a
</pre></blockquote>
<p>
It turns out that this is the result of an extension of <code>std::tuple</code>
in libc++ where they accept constructors with fewer values that
tuple elements.
<p/>
The purpose of this issue is to ask the standard to forbid
that this extension be allowed to participate in overload resolution.
</p>

<p><i>[2014-10-05, Daniel comments]</i></p>

<p>
This issue is closely related to LWG <a href="lwg-defects.html#2312" title="tuple's constructor constraints need to be phrased more precisely (Status: C++17)">2312</a><sup><a href="https://cplusplus.github.io/LWG/issue2312" title="Latest snapshot">(i)</a></sup>.
</p>

<p><i>[2014-11 Urbana]</i></p>

<p>
Moved to LEWG.
</p>
<p>
Extensions to <code>tuple</code>'s design are initially a question for LEWG.
</p>


<p id="res-2419"><b>Proposed resolution:</b></p>
<p>
This was resolved by the adoption of <a href="lwg-defects.html#2312" title="tuple's constructor constraints need to be phrased more precisely (Status: C++17)">2312</a><sup><a href="https://cplusplus.github.io/LWG/issue2312" title="Latest snapshot">(i)</a></sup> and <a href="lwg-defects.html#2549" title="Tuple EXPLICIT constructor templates that take tuple parameters end up taking references 
to temporaries and will create dangling references (Status: C++17)">2549</a><sup><a href="https://cplusplus.github.io/LWG/issue2549" title="Latest snapshot">(i)</a></sup>.
</p>





</body>
</html>
