Date: Fri, 29 Aug 2025 16:29:12 +0300
Oh, I thought that everybody wanted constexpr parameters, but nobody knows
how to approach them.
>From a library user perspective it should be easier to pass a constant to a
function and not to worry that you need to wrap it into some template that
captures its value.
And If you have constexpr parameters you can imagine being able to overload
a function on parameter "constexpr"-ness, which is currently impossible
(e.g. std::views::take that returns a view with number of taken elements
encoded in type vs current version that have to store it in range).
With reflection standardized, we will have an explosion of consteval
functions in user code, and users probably would prefer to have them as
functions not as explicit function templates.
Regards,
Gregory
пт, 29 авг. 2025 г. в 15:46, Robin Savonen Söderholm via Std-Proposals <
std-proposals_at_[hidden]>:
> Why not just use "Non Type Template Parameters"? I've understood it so
> that you have a lot more powerful things you can do with those in newer
> standards, from template template to "auto".
> For example, the following code is legal in C++-20 today:
> template<std::integral auto sz>
> std::array<decltype(sz), sz> foo () { return {}; }
>
> On Fri, Aug 29, 2025, 14:02 Григорий Шуренков via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> Hello!
>>
>> The idea of constexpr parameters is floated from time to time, but I
>> don't remember any proposals related to them.
>> The constexpr parameter is a parameter to a function that acts as a
>> constexpr variable (including the possibility to use it as a template
>> argument).
>> The value of constexpr parameter may influence the return type of the
>> function.
>>
>> Is anybody working on any such proposal now?
>>
>> I also remember someone saying that constexpr parameters are incredibly
>> hard to fit into current C++.
>> However, if we agree that a function with constexpr parameters should be
>> an (implicit) template
>> (which is hard to swallow, but I don't see any other option...), is it
>> really that difficult?
>>
>> Regards,
>> Gregory
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
how to approach them.
>From a library user perspective it should be easier to pass a constant to a
function and not to worry that you need to wrap it into some template that
captures its value.
And If you have constexpr parameters you can imagine being able to overload
a function on parameter "constexpr"-ness, which is currently impossible
(e.g. std::views::take that returns a view with number of taken elements
encoded in type vs current version that have to store it in range).
With reflection standardized, we will have an explosion of consteval
functions in user code, and users probably would prefer to have them as
functions not as explicit function templates.
Regards,
Gregory
пт, 29 авг. 2025 г. в 15:46, Robin Savonen Söderholm via Std-Proposals <
std-proposals_at_[hidden]>:
> Why not just use "Non Type Template Parameters"? I've understood it so
> that you have a lot more powerful things you can do with those in newer
> standards, from template template to "auto".
> For example, the following code is legal in C++-20 today:
> template<std::integral auto sz>
> std::array<decltype(sz), sz> foo () { return {}; }
>
> On Fri, Aug 29, 2025, 14:02 Григорий Шуренков via Std-Proposals <
> std-proposals_at_[hidden]> wrote:
>
>> Hello!
>>
>> The idea of constexpr parameters is floated from time to time, but I
>> don't remember any proposals related to them.
>> The constexpr parameter is a parameter to a function that acts as a
>> constexpr variable (including the possibility to use it as a template
>> argument).
>> The value of constexpr parameter may influence the return type of the
>> function.
>>
>> Is anybody working on any such proposal now?
>>
>> I also remember someone saying that constexpr parameters are incredibly
>> hard to fit into current C++.
>> However, if we agree that a function with constexpr parameters should be
>> an (implicit) template
>> (which is hard to swallow, but I don't see any other option...), is it
>> really that difficult?
>>
>> Regards,
>> Gregory
>> --
>> Std-Proposals mailing list
>> Std-Proposals_at_[hidden]
>> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>
Received on 2025-08-29 13:29:29