Why is converting an instance of CL to const int& ambiguous here?
struct CL { operator const int&() { } operator int&() { } }; void fnc(const int&) { } int main() { CL cl; fnc(cl); }
There are two ways:
1). cl.operator const int&() results in a custom conversion
2). cl.operator int&() leads to a custom conversion and then to a qualification conversion ( int& to const int& )
The first way is better than the second, right? I saw the Standard, but did not find anything.
source share