I've noticed a difference in behavior between Clang and GCC with following code:
class convertible {
public:
operator int() { return 1; }
template <typename T>
operator T() { return 1; }
};
int main () {
convertible x;
switch (x) {} // Clang: OK GCC: Compile error
return 0;
}
GCC returns error: default type conversion can't deduce template argument for ‘template<class T> convertible::operator T()’
Clang compiles code without errors and calls operator int()
I'm using Clang 6 and GCC 8. Both with std=c++11
Which compiler is correct in this case?