<div dir="ltr">IMO &quot;other than the callsite&quot; is not minor, it trivializes &quot;generic over is-constant-expression?&quot;<div>Or, depends how you understand details of what is proposed, </div><div>I operate under &quot;constexpr fn parameter can be either constant expression lifted to template parameter, </div><div>or regular old runtime thing&quot;, + consteval fn parameters that reject latter.</div><div><br></div><div>```cpp<div>void foo(float* ptr, constexpr size_t len) { ... }<br><br>std::array&lt;float, 5&gt; arr = ...;<br>foo(arr.data(), arr.size()); // foo&lt;5&gt;(float*)</div><div>std::vector&lt;float&gt; vec = ...;</div><div>foo(vec.data(), vec.size()); // foo(float*, size_t)</div><div>```</div><div><br></div><div>Relevant proposal: P1045 - constexpr Function Parameters</div><div><a href="https://web.archive.org/web/20261110020406/https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1045r1.html">https://web.archive.org/web/20261110020406/https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1045r1.html</a></div><div><a href="https://github.com/cplusplus/papers/issues/603">https://github.com/cplusplus/papers/issues/603</a></div></div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Nov 26, 2026 at 11:35 AM Miguel Veganzones 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 dir="auto">What would be the difference with a normal template parameter other than the callsite?<div dir="auto"><br></div><div dir="auto">I am not too familiar with std::cw, but it seems to solve a common issue for me: a function can be implemented with a compile time size or a runtime size, but compile time information is preferable if available. Such a function could accept &#39;auto size&#39;, check if this value is a constant literal, and specialize accordingly. In such scenario the caller can provide runtime or compile time information to the callee without knowing it itself wether this information is usable at compile time.</div><div dir="auto"><br></div><div dir="auto">Just my two cents on it.</div><div dir="auto"><br></div><div dir="auto">Miguel</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">El jue, 26 nov 2026, 10:58, David Brown via Std-Proposals &lt;<a href="mailto:std-proposals@lists.isocpp.org" rel="noreferrer" target="_blank">std-proposals@lists.isocpp.org</a>&gt; escribió:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">In C++26, we now have std::constant_wrapper&lt;&gt; and std::cw&lt;&gt; which can <br>
let you pass constant expressions as normal function parameters, and let <br>
them be used as constant expressions within the function definition. <br>
(We are talking about templated functions here, since each <br>
std::constant_wrapper&lt;&gt; instance has a unique type for the value it wraps.)<br>
<br>
 From cppreference, we have the example :<br>
<br>
        auto make_filled(auto size, int value)<br>
        {<br>
            std::array&lt;int, size&gt; a;<br>
            a.fill(value);<br>
            return a;<br>
        }<br>
<br>
This can be called from other code as :<br>
<br>
        auto a = make_filled(std::cw&lt;3&gt;, x);<br>
<br>
Then &quot;a&quot; is a std::array&lt;3, int&gt; filled with the value of &quot;x&quot;.<br>
<br>
Prior to C++26, you would write this as :<br>
<br>
        template&lt;size_t size&gt;<br>
        auto make_filled(int value)<br>
        {<br>
            std::array&lt;int, size&gt; a;<br>
            a.fill(value);<br>
            return a;<br>
        }<br>
<br>
        auto a = make_filled&lt;3&gt;(x);<br>
<br>
<br>
The use of std::constant_wrapper&lt;&gt; can make the code a little neater and <br>
more consistent - the call site only uses function arguments and does <br>
not also need template arguments, and these can be given in the function <br>
definition in whatever order makes sense.<br>
<br>
But it means that every call needs to have &quot;std::cw&lt;&gt;&quot; wrappers <br>
explicitly added - that is more code at each call, more to add, more to <br>
get right, more to understand.<br>
<br>
<br>
My suggested alternative syntax here would be :<br>
<br>
        auto make_filled(constexpr size_t size, int value)<br>
        {<br>
            std::array&lt;int, size&gt; a;<br>
            a.fill(value);<br>
            return a;<br>
        }<br>
<br>
        auto a = make_filled(3, x);<br>
<br>
<br>
Function parameters with the &quot;constexpr&quot; specifier would effectively be <br>
non-type template parameters.  This would be another kind of abbreviated <br>
template, in the same sense as the use of concepts or &quot;auto&quot; in place of <br>
types for function parameters.  A &quot;constepxr&quot; parameter could be of <br>
fixed type, &quot;auto&quot;, a concept, etc., just like any other parameter.<br>
<br>
The advantage of this would be to give neater and more &quot;universal&quot; <br>
calling code for template functions with non-type template parameters. <br>
The disadvantage is that it hides the fact that the &quot;size&quot; parameter in <br>
this example must be a constant expression, not a runtime value.<br>
<br>
<br>
Any thoughts here?  Is it an idea that appeals to people, or would it <br>
feel like it is hiding important information?  Or am I missing something <br>
crucial that would make this impossible or impractical?<br>
<br>
David<br>
<br>
<br>
<br>
<br>
-- <br>
Std-Proposals mailing list<br>
<a href="mailto:Std-Proposals@lists.isocpp.org" rel="noreferrer noreferrer" target="_blank">Std-Proposals@lists.isocpp.org</a><br>
<a href="https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals" rel="noreferrer noreferrer noreferrer" target="_blank">https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals</a><br>
</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>
</blockquote></div>

