[Bug c++/84855] structered bindings require "decomposed" type to be copy'able

h2+bugs at fsfe dot org gcc-bugzilla@gcc.gnu.org
Wed Mar 14 12:41:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84855

--- Comment #5 from Hannes Hauswedell <h2+bugs at fsfe dot org> ---
Sure, that follows from the definition "For each identifier, a variable whose
type is "reference to std::tuple_element<i, E>::type" is introduced".
This wouldn't have to be implemented like this, though...

My original intuition (and probably that of others) was that 
auto CR [ a, b ] = f;

leads to 

auto CR a = std::get<0>(f);
auto CR b = std::get<1>(f);

where CR can be "", "&", "&&" or "const &".

Instead something like this happens:
auto CR e = f;
auto && a = std::get<0>(e);
auto && b = std::get<1>(e);

I assume this design was chosen to be able to materialise temporaries and I
don't see an obvious way of handling that with a different design. But I still
feel like it is less intuitive in the general case and in my case also prevents
the plan (because I explicitly don't want perfect forwarding).

But that's a different matter and I will stop wasting your dev time ;-)


More information about the Gcc-bugs mailing list