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@lists.isocpp.org> On Behalf Of Raymund Hofmann via Std-Discussion
Sent: Friday, January 24, 2020 7:23 AM
To: std-discussion@lists.isocpp.org
Cc: Raymund Hofmann <hofmannraymund@gmail.com>
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 f()

{

auto adhocstruct=[m=expression_m, n=expression_n];

 

g(adhocstruct.m+adhocstruct.n);

h(adhocstruct);

 

return adhocstruct;

}

 

auto sometransform()

{

...

return [result=expression, tolerance=expression, moved=std::move(movedfrom)];

}

 

decltype(sometransform()) sometransformresultvalue;

 

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.