Strange error with a templated operator overload
When I compile the following snippet, I get a compiler error with clang, but not with g++/MSVC: #include <string> template<typename T> struct Const { explicit Const(T val) : value(val) {} T value; }; template<typename T> struct Var { explicit Var(const std::string &n) : name(n) {} std::string name; }; template<typename L, typename R> struct Greater { Greater(L lhs, R rhs) : left(lhs), right(rhs) {} L left; R right; }; template<typename L> Greater<L, Const<int> > operator > (L lhs, int rhs) { return Greater<L, Const<int> >(lhs, Const<int>(rhs)); } template<typename R> Greater<Const<int>, R>