Date: Thu, 20 Apr 2023 22:54:54 +0300
On Thu, 20 Apr 2023 at 22:49, Frederick Virchanza Gotham via
Std-Proposals <std-proposals_at_[hidden]> wrote:
> > > auto mylambda = [arg](void) -> int
> > > {
> > > return arg + 3;
> > > };
> >>
> > to
> > >
> > > struct {
> > > int arg;
> > > auto operator()() const -> int { return arg + 3; }
> > > } mylambda = { arg };
>
>
>
> This argument can be made for __every__ lambda that was ever written.
No it can't.
> We can replace them all with structs. But lambdas are all about
> neatness and convenience.
Convenience of capturing surrounding state, yes, convenience of
representing every other use case
of function objects, no.
Std-Proposals <std-proposals_at_[hidden]> wrote:
> > > auto mylambda = [arg](void) -> int
> > > {
> > > return arg + 3;
> > > };
> >>
> > to
> > >
> > > struct {
> > > int arg;
> > > auto operator()() const -> int { return arg + 3; }
> > > } mylambda = { arg };
>
>
>
> This argument can be made for __every__ lambda that was ever written.
No it can't.
> We can replace them all with structs. But lambdas are all about
> neatness and convenience.
Convenience of capturing surrounding state, yes, convenience of
representing every other use case
of function objects, no.
Received on 2023-04-20 19:55:08