This code fails to compile using MSVC 19.27.29112.0, but works with GCC 10.2.0. C++20 is enabled in both cases:
template <typename T>
struct Blah {
void blah() requires (sizeof(T) == 4);
};
template <typename T>
void Blah<T>::blah() requires (sizeof(T) == 4) {}
int main() {
Blah<int> b;
b.blah();
return 0;
}
error C2511: 'void Blah::blah(void)': overloaded member function not found in 'Blah'
The error only occurs if the requires depends on the class's template type. For example, requires (sizeof(int) == 4) works fine. Converting blah() to a templated function and doing something like requires (sizeof(U) == 4) also works.
Can anyone confirm this is a compiler bug?