Is std::array movable?
In Bjarne Native 2012 presentation slides (slide 41) it lists std::array
as one of the only containers that isn't movable.
A quick look on gcc 4.8 libraries source code seems to confirm that std::array
is not movable:
std::vector:
/* @brief %Vector move constructor.
... */
vector(vector&& __x) noexcept
: _Base(std::move(__x)) { }
while in std::array the only method that receives a rvalue reference parameter is the random element access, which avoids a return by copy:
get(array<_Tp, _Nm>&& __arr) noexcept
{ /*...*/ return std::move(get<_Int>(__arr)); }
Is move-constructor and move-assignment for std::array
defaulted created, or is std::array
unmovable? If it is unmovable, why std::array
cannot be moved while std::vector
can?