This code compile fine with clang and gcc.
template<size_t n>
struct N {
static constexpr size_t v = n;
};
template<size_t n>
constexpr bool operator<(N<n>, size_t n2) {
return n < n2;
}
template<typename N>
constexpr void foo(N v) {
static_assert(v < 5);
}
int main()
{
foo(N<3>{});
return 0;
}
However, if I use MSVC, I got the error that v < 5 is not a constant expression. I can understand why MSVC thinks that, but I think it is wrong and clang / gcc are right. Is it a bug from MSVC?