Subject: Re: Idea: lambda capture list as ad-hoc structure or named members tuple
From: Michael Hava (mfh_at_[hidden])
Date: 2020-01-24 07:47:12
Purely personal opinion: the last thing C++ (ATM) needs is yet another special syntax with limited applicability...
I'd rather restart the discussion on lifting the restriction on local templates... (aka. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1988r0.html)
From: Std-Discussion <std-discussion-bounces_at_[hidden]> On Behalf Of Raymund Hofmann via Std-Discussion
Sent: Friday, January 24, 2020 7:23 AM
Cc: Raymund Hofmann <hofmannraymund_at_[hidden]>
Subject: [std-discussion] Idea: lambda capture list as ad-hoc structure or named members tuple
So why not have something like a capture list of a lambda with outside access of its named auto typed members?
A kind of structured binding with initializing expressions for each member?
auto adhocstruct=[m=expression_m, n=expression_n];
return [result=expression, tolerance=expression, moved=std::move(movedfrom)];
Using tuples for that has a major drawback of not being able to give descriptive names for members.
Using predefined structs has three major drawbacks: more typing/code (DRY), less locality and no auto member type deduction.
STD-DISCUSSION list run by email@example.com
Older Archives on Google Groups