Why is the conversion of CL
instance 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&()
leads to user-defined conversion
2). cl.operator int&()
leads to user-defined conversion and then qualification conversion (int&
to const int&
)
First way is better than second way, isn't it? I saw Standard, but found nothing.