I implemented two conversions for a class. One is to bool, one is to int&.
If I implicitly convert to int, it uses the int& conversion, but if I want a bool, it still uses the int& conversion.
struct A
{
operator bool() const;
operator int&();
};
// trying to call these:
A a;
int i_test = a; // calls operator int&()
bool b_test = a; // calls operator int&()
I understand that a is implicitly converted to int& and then to bool, but why does it take that longer path? How can I avoid it without having to write a.operator bool()?