C++ Logo

STD-PROPOSALS

Advanced search

Subject: Re: [std-proposals] Remove non-type template limitations for consteval functions
From: Bastien penavayre (bastienpenava_at_[hidden])
Date: 2021-02-24 12:24:20


On 24/02/2021 12:57, Robert J. Simpson via Std-Proposals wrote:
> One of the requirements is that types must be comparable and in the case
of non-type templates that means comparing values. E.g. if you have a
'const char*' value then what does it mean for two of these values to be
equal?

Yes indeed and the reason why we needed comparable types is that we can
separate instantiation of a template and its usage.

For instance, we can:
- prototype a template
- use it
- give its definition later / give it in a different TU and instantiate it
with the desired value

template<auto T>
void func();

auto func_int = &func<42>;
template<auto T>
void func() {}

//or in different TU
template<auto T>
void func();

template<>
void func<42>();

But this isn't the case for consteval function as can't use them before
they're defined nor get their address.

Therefor for a consteval function the comparable requirement isn't meaning
full, it's just a leftover of previous unrelated constrains.



STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups