ARTICLE AD BOX
I’m experimenting with C++20 concepts and encountered a compiler discrepancy.
This code compiles on Clang 17 and GCC 13, but MSVC (VS2022) rejects it:
template <typename T> concept HasFoo = requires(T t) { { t.foo() } -> std::same_as<int>; }; template <HasFoo T> void callFoo(T t) { std::cout << t.foo(); } struct X { int foo() const { return 42; } }; int main() { X x; callFoo(x); }MSVC error:
error C7602: 'callFoo': the associated constraints are not satisfiedWhy does MSVC fail template argument deduction here, and is this a known compiler bug or a subtle rule I’m missing?
