Date: Thu, 20 Apr 2023 17:05:42 +0200
Il 20/04/23 16:35, Frederick Virchanza Gotham via Std-Proposals ha scritto:
>
> How about allowing the creation of new lambda object (with captures)
> by using initialiser braces?
How about it? Write a proposal that changes how the closure type looks
like, so to allow that kind of list initialization (what kind of
initialization precisely should be performed and how?), and be sure to
add compelling motivation to it. Because otherwise the natural objection
is that _today_ you can simply go from
>
> auto Func(int const arg)
> {
> auto mylambda = [arg](void) -> int
> {
> return arg + 3;
> };
>
> return mylambda;
> }
to
>
> struct {
> int arg;
> auto operator()() const -> int { return arg + 3; }
> } mylambda = { arg };
>
> return mylambda;
And then you're good to go.
>
> How about allowing the creation of new lambda object (with captures)
> by using initialiser braces?
How about it? Write a proposal that changes how the closure type looks
like, so to allow that kind of list initialization (what kind of
initialization precisely should be performed and how?), and be sure to
add compelling motivation to it. Because otherwise the natural objection
is that _today_ you can simply go from
>
> auto Func(int const arg)
> {
> auto mylambda = [arg](void) -> int
> {
> return arg + 3;
> };
>
> return mylambda;
> }
to
>
> struct {
> int arg;
> auto operator()() const -> int { return arg + 3; }
> } mylambda = { arg };
>
> return mylambda;
And then you're good to go.
-- Giuseppe D'Angelo
Received on 2023-04-20 15:05:45