문제

For example,

struct A {};

struct B
{
    B(A&& a)
       : mA(std::move(a)) // Is A's constructor called here?
    {}

    A&& mA;
};

Is A's constructor called in the initialization list of B? Or it's like a reference implemented by a pointer?

도움이 되었습니까?

해결책

No; mA is not an object but merely a reference, so there is nothing to construct.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top