Let's say we have a consteval function or a trivial struct with consteval construnctor, which only accept some of the values:
struct A
{
consteval A(int a)
{
// compile error if a < 0
if (a < 0)
throw "error";
}
};
Is there any way to detect if a non-type template parameter of int could be accepted by such a constructor? I have tried the following code but failed.
template <int a> concept accepted_by_A = requires() {A(a);};
int main()
{
std::cout << accepted_by_A<-1> << std::endl; // output 1 (true)
}