Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top