c++ - Should std::array have move constructor? -


moving can't implemented efficiently (o(1)) on std::array, why have move constructor ?

std::array has compiler generated move constructor, allows elements of 1 instance moved another. handy if elements efficiently moveable or if movable:

#include <array> #include <iostream>  struct foo {   foo()=default;   foo(foo&&)   {     std::cout << "foo(foo&&)\n";   }   foo& operator=(foo&&)   {     std::cout << "operator=(foo&&)\n";     return *this;   } };  int main() {   std::array<foo, 10> a;   std::array<foo, 10> b = std::move(a); } 

so std::array should have move copy constructor, specially since comes free. not have 1 require actively disabled, , cannot see benefit in that.


Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -