Skip to content

Commit

Permalink
New issue from Jiang An: "Contradictory specification of std::tuple_s…
Browse files Browse the repository at this point in the history
…ize"
  • Loading branch information
Dani-Hub committed Jan 20, 2024
1 parent d62c140 commit 76a3faa
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions xml/issue4040.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version='1.0' encoding='utf-8' standalone='no'?>
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">

<issue num="4040" status="New">
<title>Contradictory specification of <tt>std::tuple_size</tt></title>
<section><sref ref="[ostream.formatted.print]"/></section>
<submitter>Jiang An</submitter>
<date>20 Jan 2024</date>
<priority>99</priority>

<discussion>
<p>
<sref ref="[tuple.helper]"/>/1 currently says:
</p>
<blockquote>
<p>
All specializations of <tt>tuple_size</tt> meet the <i>Cpp17UnaryTypeTrait</i> requirements
(<sref ref="[meta.rqmts]"/>) with a base characteristic of <tt>integral_constant&lt;size_t, N&gt;</tt>
for some <tt>N</tt>.
</p>
</blockquote>
<p>
which is probably wrong for <tt>std::tuple_size&lt;int&gt;</tt> and
<tt>std::tuple_size&lt;std::vector&lt;int&gt;&gt;</tt> whose definitions are not provided, and
contradicts with <sref ref="[tuple.helper]"/>/4
</p>
<blockquote>
<p>
[&hellip;] Otherwise, it has no member <tt>value</tt>.
</p>
</blockquote>
<p>
Also, there's currently implementation divergence on whether <tt>std::tuple_size&lt;<i>cv</i> T&gt;</tt>
is a complete type when <tt>std::tuple_size&lt;T&gt;::value</tt> is absent (related to LWG <iref ref="2770"/>).
Some implementations (e.g.
<a href="https://github.com/llvm/llvm-project/blob/b1d4265a5f5345065e5c2aedf50787da05ddcc08/libcxx/include/__tuple/tuple_size.h#L29-L47">libc++</a>
and <a href="https://github.com/gcc-mirror/gcc/blob/615e25c82de97acc17ab438f88d6788cf7ffe1d6/libstdc%2B%2B-v3/include/bits/utility.h#L55-L71">libstdc++</a>)
treat <sref ref="[tuple.helper]"/>/4 and <sref ref="[depr.tuple]"/>/2 as "<tt>std::tuple_size&lt;<i>cv</i> T&gt;</tt>
is generated from partial specializations only if <tt>std::tuple_size&lt;T&gt;</tt> meets the aforementioned conditions",
while others (e.g. <a href="https://github.com/microsoft/STL/blob/442029c6fa37f1b6f9203357de09672d5704077c/stl/inc/utility#L598-L612">MSVC STL</a>)
always consider <tt>std::tuple_size&lt;<i>cv</i> T&gt;</tt> needs to be defined. The latter
reading seems to be justified by <sref ref="[contents]"/>/1 and <sref ref="[tuple.syn]"/>.
</p>
</discussion>

<resolution>
</resolution>

</issue>

0 comments on commit 76a3faa

Please sign in to comment.