I try to have a member function require a static constexpr boolean member to be true. This would be very helpful to DRY a quite complex requirement. And I do not quire get the reason why the compiler won't let me.
Minimal example with slightly less complex requirement:
template <typename T>
struct Foo
{
static constexpr bool isInt = std::integral<T>;
void bar() requires (isInt);
void goo() requires std::integral<T>;
};
template <typename T>
void Foo<T>::bar() requires (Foo<T>::isInt) // error: out-of-line definition of 'bar' does not match any declaration in 'Foo<T>' x86-64 clang 14.0.0 #1
{
// ...
}
template <typename T>
void Foo<T>::goo() requires std::integral<T> // ok
{
// ...
}
Is this because isInt
is declared inside the same class? Or do I have some kind of syntax error?