I'm reading about move semantic in C++11 and now I'm trying to understand the implementation of the move constructor. Suppose that we have the following class:
struct A {
A(){ }
virtual ~A(){ }
A(const A&&){ }
};
struct B{
int i;
A a;
virtual ~B(){ }
B(const B&& b){
i = b.i;
i = 0;
//How to move a??
}
};
My question is how to invoke the A
's move constructor inside B
's one body? I'd use std::swap
, but looking for it I found some description. The arguments are of the lvalue reference type, so it has nothing to do with move semantic. What to do?