I can't find the correct syntax on cpprefference for a concept that matches the value of a static constexpr member. This code compiles, and functions correctly on GCC and MSVC, but does not work in Clang. I was wondering if anybody knew if this was my mistake, or an issue with either GCC and MSVC or Clang?
Here's a godbolt with all three compilers open, I think it illustrates the point!
#include <concepts>
#include <iostream>
template<typename T>
concept MyConcept = requires (T t){
requires t.member == 1;
//[clang's error]
// note: because 't.member == 1' would be invalid:
// constraint variable 't' cannot be used in an evaluated context
};
struct S {
constexpr static int member {2};
};
struct D {
constexpr static int member {1};
};
template<MyConcept T>
void func(){
std::cout << "matched\n";
}
int main(){
func<D>();
return 0;
}