Here's some example code showing these features:
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/505fe073-a45b-4974-b1cb-df03ea39a5c6%40isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/b236289c-3757-4047-a1b4-7781148af265%40isocpp.org.
I would find the feature more useful if it offered slightly less functionality; in particular, I'd like a guarantee that no operation at all can be performed on such variables except the automatic destruction at end of scope.
To these ends, would it make sense to dispense with the variable name altogether, making the objects truly anonymous?
auto = std::lock_guard<std::mutex>(mtx1);
auto = std::lock_guard<std::mutex>(mtx2);
g++ -std=c++14 -O2 -Wall -pedantic -pthread main.cpp && ./a.out
main.cpp: In function 'int main()':
main.cpp:10:9: warning: unused variable 'b' [-Wunused-variable]
int b(0);
Related: I just noticed that it seems compiler writers have to special-case treatment of
std guards to not give unused variable warnings?
_ is already used as a placeholder in the MPL. It's also sometimes used as a local macro name. You have a neat idea, but _ seems pretty well spoken for. It's also unclear that this proposal would solve a real pain point, or whether it's convenience would be outweighed by (arguably) less readable code.
I would find the feature more useful if it offered slightly less functionality; in particular, I'd like a guarantee that no operation at all can be performed on such variables except the automatic destruction at end of scope.
On 10 July 2016 at 15:10, <je...@unbuggy.com> wrote:_ is already used as a placeholder in the MPL. It's also sometimes used as a local macro name. You have a neat idea, but _ seems pretty well spoken for. It's also unclear that this proposal would solve a real pain point, or whether it's convenience would be outweighed by (arguably) less readable code.
I would find the feature more useful if it offered slightly less functionality; in particular, I'd like a guarantee that no operation at all can be performed on such variables except the automatic destruction at end of scope.This is, of course the problem. You are looking to change functionality which has been there since C90 (or even longer). This would break working code and introduce an incompatibility with C. You could possibly mitigate the latter with a complicated rule (for instance, it only has the desired semantics for types with non-trivial destructors), but if you are stealing a name, you cannot help but break the former.
auto [a, b] = ...;
auto &&temp = make_pair(3, 4.5f);
auto &a = temp.first;
auto &b = temp.second;
auto [] = ...;
auto[] = scope_exit(...);
That's interesting Nicol, but what about the other cases? For structured binding itself
for example, how would I let bindings unnamed?
On Sun, Jul 10, 2016 at 6:44 PM, Nicol Bolas <jmck...@gmail.com> wrote:
> Wait a minute. Let's think about what we just added to C++: structured
> binding:
>
> auto [a, b] = ...;
Currently this syntax is outlawed,
Don't try to solve every problem at once.
Besides _ or __ I'm thinking of other possibilities...
@: I know of its presence solely in mangled names but I suspect it won't be an issue.
I dunno, maybe the range of special characters may be of some use here too.
Em domingo, 10 de julho de 2016 23:08:39 UTC-3, Francisco Lopes escreveu:Besides _ or __ I'm thinking of other possibilities...
@: I know of its presence solely in mangled names but I suspect it won't be an issue.
I dunno, maybe the range of special characters may be of some use here too.
If adopting such alternative characters, it would be placeholder only, without referentiability.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposal...@isocpp.org.
To post to this group, send email to std-pr...@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/69941075-9183-403b-86ac-3e37b7ddfae1%40isocpp.org.