Reputation: 2137
We have these classes:
struct Intermediate : public std::array<double,3> {};
struct Vector3 : public Intermediate
{
// ........more ctors.........
// Modified move constructor (base class)
Vector3(std::array<double,3> &&v) { ??????? }
// ........more functionality...........
};
Is the "modified" move constructor act like original move constructor?
How can I implement the constructor? Is there another way than std::array::swap?
Upvotes: 0
Views: 277
Reputation: 171263
You could do this:
Vector3(std::array<double,3> &&v)
{ static_cast<std::array<double,3>&>(*this) = std::move(v); }
This move-assigns v
to the base class of this
But that move constructor seems pretty pointless. When you move
an array of double
it will just do a copy anyway. double
has no move semantics, only copy semantics, and array<double,N>
contains the array directly within it, so cannot move it to another object.
Upvotes: 2