Non-const copy constructor and implicit conversions on return value

前端 未结 4 722
长发绾君心
长发绾君心 2020-12-31 23:51

Consider the following C++ code:

struct B { };
struct A
{
        A(int);
        A(A&); // missing const is intentional
        A(B);
        operator B         


        
4条回答
  •  死守一世寂寞
    2021-01-01 00:21

    Because you cannot do more than one implicit conversion. You would have to go A::A(A::A(int)::operator B()) to make that work, and that's way too many steps for the compiler to figure out on it's own.

提交回复
热议问题