Does copy elision work with structured bindings

Viewed 1865

Does mandatory copy elision apply to decomposition via structured bindings? Which of the following cases does that apply to?

// one
auto [one, two] = std::array<SomeClass>{SomeClass{1}, SomeClass{2}};

// two
auto [one, two] = std::make_tuple(SomeClass{1}, SomeClass{2});

// three
struct Something { SomeClass one, two; };
auto [one, two] = Something{};    

I suspect only the third case allows for copy elision, since the first two will be "decomposed" via std::get<> and std::tuple_size<> and std::get<> returns xvalues when the arguments are rvalues

A quote from the standard would be nice also!

2 Answers
Related