Bug ID: 84855
           Summary: structered bindings require "decomposed" type to be
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot
          Reporter: h2+bugs at fsfe dot org
  Target Milestone: ---

Created attachment 43647

If I do

foobar f; // has tuple-like interface
auto [ a, b ] = f;

Then for some reason foo needs to be copyable and I don't understand why, i.e.
perceive this as a bug, although both GCC and Clang require it.

I have attached a file that illustrates this. I would assume that invoking the
structed bindings just calls get() twice on the f, but gobolting the attached
code without optimisations reveals that indeed f is being copied.

And the actual problem is that explicitly deleting the copy-constructor of
foobar makes the build fail.

Like I said, maybe I am missing something here, but why would there be a copy
involved of type f. [Obviously there is copy involved of the members of f,
depending on the return type of get(), but that's a different matter from f].

Thank you for your help!

Confirmed on
g++-7 (Debian 7.3.0-8)
g++-8 (Debian 8-20180308-1)
clang version 5.0.1-2

Reply via email to