C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Constexpr parameters

From: Robin Savonen Söderholm <robinsavonensoderholm_at_[hidden]>
Date: Fri, 29 Aug 2025 14:46:34 +0200
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
>

Received on 2025-08-29 12:46:49