c++ - Move semantics between base classes -
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 "modified" move constructor deed original move constructor?
how can implement constructor? there way std::array::swap?
you this:
vector3(std::array<double,3> &&v) { static_cast<std::array<double,3>&>(*this) = std::move(v); }
this move-assigns v
base of operations class of this
but move constructor seems pretty pointless. when move
array of double
re-create anyway. double
has no move semantics, re-create semantics, , array<double,n>
contains array straight within it, cannot move object.
c++ c++11 move-semantics
No comments:
Post a Comment