<div dir="ltr"><div>The issue with the first(array of  std::variant&lt;T&amp;... or T*... or T const*&gt;  ) is that it is not guaranteed to be fast(Again, the implementation knows better) and it also dosent support tuples storing the objects, which again, leads to less control over the life times of the objects, which isnt always type safe since the T&amp; in the array may refer to a T object that does not exist.</div><div><br></div><div>The issue with modifying existing tuples is that current ABIs designed for certain tuple specializations will expect the tuple to be like existing tuples, and by include subscript operator in existing tuples would mean that the tuple cant be optimized without breaking existing code and/or the zero overhead principle. The possible optimizations are as I discussed bookkeeping information like storing an array of variants or anything the implementation sees fit. </div><div><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Apr 17, 2026 at 2:52 PM Sebastian Wittmeier via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org">std-proposals@lists.isocpp.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg4462489039058498140"><u></u>

  
  
  
  

<div>
<p>So from a low-level perspective you basically would create an array of pointers (references are typically implemented as pointers) and everything a bit more type-safe.</p><p> </p><p>Yes, could make sense to standardize.</p><p> </p><p> </p><p>But the two alternatives are also looking good:</p><p> </p><p>1) Standardize std::variant&lt;&amp;T1, &amp;T2, ...&gt; und use a std::array of std::variant. Less type-safe. But nice enough.</p><p> </p><p>2) Change std::tuple to return a std::variant&lt;&amp;T1, &amp;T2, ...&gt;. by runtime index. The std::variant is not inside the type, but is created on the fly. If you have a single pointer and a type specifier inside your std::variant, it is small enough to be created on-the-fly and passed in registers to other functions.</p><p> </p><p> </p><p>I think I like 2) best.</p><p><br> </p><blockquote style="border-left:2px solid rgb(50,95,186);padding-left:5px;margin-left:5px">-----Ursprüngliche Nachricht-----<br><strong>Von:</strong>	Muneem via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org" target="_blank">std-proposals@lists.isocpp.org</a>&gt;<br><strong>Gesendet:</strong>	Fr 17.04.2026 11:42<br><strong>Betreff:</strong>	Re: [std-proposals] Extension to std::tuples to allow runtime indexing.<br><strong>An:</strong>	<a href="mailto:std-proposals@lists.isocpp.org" target="_blank">std-proposals@lists.isocpp.org</a>; <br><strong>CC:</strong>	Muneem &lt;<a href="mailto:itfllow123@gmail.com" target="_blank">itfllow123@gmail.com</a>&gt;; <br>  <div dir="ltr">1.I dont want that optimization but if the implementation sees it as fit then it would. <div>2.  The reason for the std::variant&lt;T&amp;...&gt; to be proposed is to avoid the exact space overhead that you are talking about. <div>3.std::array&lt;std::variant&lt;double, int, float&gt;, 3&gt; isn&#39;t guaranteed to be fast, similarly it might encourage people to make many variants of this implementation, which again is ad hoc and messy. What needs to exist is a standard interface that the implementation can implement in whatever way it sees fit, so that the runtime tuple is fast and people dont reinvent the wheel. In fact, in your case, you also had a temptation to reconsider: std::fixed_variant_array&lt;double, int, float&gt;, which again means that on large scale, many people will implement many of these, leading to a mess like openssl&#39;s C api implementation where everything openssl made and little to nothing is borrowed from the C standard library, which in my case, made me be scared of cryptography and networking libraries for a whole year.</div></div></div> <pre>-- 
 Std-Proposals mailing list
 <a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank">Std-Proposals@lists.isocpp.org</a>
 <a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a>
 </pre>  </blockquote>
</div>
-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</div></blockquote></div></div>

