New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CAPTURE of structured binding element no longer works #279
Comments
more bugs with newer versions: doctest/doctest#280 doctest/doctest#279
........ This works with GCC but fails with clang (haven't tested MSVC). You could work it around by making a separate We won't revert to the old implementation of Btw it's impressive that you've tracked down the commit which caused this - in this case it didn't matter much but I wish more bug reports were as thorough as yours! |
The funny thing is, I already had a macro for that workaround you suggested because of the rvalue limitation... looks like I no longer need it for rvalues, but now I need structured bindings. Am I the only one who feels c++ standards got buggier recently? |
it won't work in the following case: I don't know what the user will be capturing so the capture has to be |
releasing 2.3.5 |
This is not a bug in a compiler (nor in the standard), but a deliberate decision. The standard says structured bindings are no variables, and thus cannot be captured. (See the discussion here with relevant links.) |
Description
Take a look at the example below where I capture a variable from a structured binding. With 2.3.3 and before it worked fine, with 2.3.4 I receive an error like this:
It looks like it was broken in 5e493d3
Steps to reproduce
Compile it with
clang++ -std=c++17
. It also fails if I use an std::pair/tuple instead of an array.Extra information
The text was updated successfully, but these errors were encountered: