In the following code
struct S {
operator auto() { return 42; }
};
operator auto is equivalent to operator int since actual type would be deduced from the literal 42 and that type is int. If I write 42.5 instead of 42 then operator auto would be interpreted as operator double for obvious reason. But when I use both at the same time I got a compiler error for all three major compilers (gcc, clang, msvc):
struct S {
operator auto() { return 42; }
operator auto() { return 42.5; }
};
Actual error messages are vary among compilers, but the reason is the same: "Function already defined".
I can't find in standard why the both operator auto (with different return type) can't be used simultaneously in one class. Could someone point me to the standard's clause where that set of conversion functions considered as forbidden?