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

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -