| 
 | 1 | +<?xml version='1.0' encoding='utf-8' standalone='no'?>  | 
 | 2 | +<!DOCTYPE issue SYSTEM "lwg-issue.dtd">  | 
 | 3 | + | 
 | 4 | +<issue num="4040" status="New">  | 
 | 5 | +<title>Contradictory specification of <tt>std::tuple_size</tt></title>  | 
 | 6 | +<section><sref ref="[ostream.formatted.print]"/></section>  | 
 | 7 | +<submitter>Jiang An</submitter>  | 
 | 8 | +<date>20 Jan 2024</date>  | 
 | 9 | +<priority>99</priority>  | 
 | 10 | + | 
 | 11 | +<discussion>  | 
 | 12 | +<p>  | 
 | 13 | +<sref ref="[tuple.helper]"/>/1 currently says:  | 
 | 14 | +</p>  | 
 | 15 | +<blockquote>  | 
 | 16 | +<p>  | 
 | 17 | +All specializations of <tt>tuple_size</tt> meet the <i>Cpp17UnaryTypeTrait</i> requirements   | 
 | 18 | +(<sref ref="[meta.rqmts]"/>) with a base characteristic of <tt>integral_constant<size_t, N></tt>   | 
 | 19 | +for some <tt>N</tt>.  | 
 | 20 | +</p>  | 
 | 21 | +</blockquote>  | 
 | 22 | +<p>  | 
 | 23 | +which is probably wrong for <tt>std::tuple_size<int></tt> and   | 
 | 24 | +<tt>std::tuple_size<std::vector<int>></tt> whose definitions are not provided, and   | 
 | 25 | +contradicts with <sref ref="[tuple.helper]"/>/4  | 
 | 26 | +</p>  | 
 | 27 | +<blockquote>  | 
 | 28 | +<p>  | 
 | 29 | +[…] Otherwise, it has no member <tt>value</tt>.  | 
 | 30 | +</p>  | 
 | 31 | +</blockquote>  | 
 | 32 | +<p>  | 
 | 33 | +Also, there's currently implementation divergence on whether <tt>std::tuple_size<<i>cv</i> T></tt>   | 
 | 34 | +is a complete type when <tt>std::tuple_size<T>::value</tt> is absent (related to LWG <iref ref="2770"/>).   | 
 | 35 | +Some implementations (e.g.   | 
 | 36 | +<a href="https://github.com/llvm/llvm-project/blob/b1d4265a5f5345065e5c2aedf50787da05ddcc08/libcxx/include/__tuple/tuple_size.h#L29-L47">libc++</a>   | 
 | 37 | +and <a href="https://github.com/gcc-mirror/gcc/blob/615e25c82de97acc17ab438f88d6788cf7ffe1d6/libstdc%2B%2B-v3/include/bits/utility.h#L55-L71">libstdc++</a>)   | 
 | 38 | +treat <sref ref="[tuple.helper]"/>/4 and <sref ref="[depr.tuple]"/>/2 as "<tt>std::tuple_size<<i>cv</i> T></tt>   | 
 | 39 | +is generated from partial specializations only if <tt>std::tuple_size<T></tt> meets the aforementioned conditions",   | 
 | 40 | +while others (e.g. <a href="https://github.com/microsoft/STL/blob/442029c6fa37f1b6f9203357de09672d5704077c/stl/inc/utility#L598-L612">MSVC STL</a>)   | 
 | 41 | +always consider <tt>std::tuple_size<<i>cv</i> T></tt> needs to be defined. The latter   | 
 | 42 | +reading seems to be justified by <sref ref="[contents]"/>/1 and <sref ref="[tuple.syn]"/>.  | 
 | 43 | +</p>  | 
 | 44 | +</discussion>  | 
 | 45 | + | 
 | 46 | +<resolution>  | 
 | 47 | +</resolution>  | 
 | 48 | + | 
 | 49 | +</issue>  | 
0 commit comments