c++ - Move constructors and `std::array` -


according n3485 §23.3.2.2:

(...) implicit move constructor , move assignment operator array require t moveconstructible or moveassignable, respectively.

so, std::array supports move semantics if type of elements does. great!

however, mean? tend picture type safer version of array providing stl-compliant interface but, if true, how can std::array move-construct elements? can same ordinary array?

however, mean?

it means that, if element type movable, array type.

std::array<movable, 42> move_from = {...}; std::array<movable, 42> move_to = std::move(move_from); // moves elements 

i tend picture type safer version of array providing stl-compliant interface

not really. it's wrapper array, giving same semantics aggregate class - including ability copy , move it.

how can std::array move-construct elements?

in same way other aggregate. implicit move-constructor move-construct members, including elements of member arrays.

can same ordinary array?

only if wrap in class type, std::array does.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -