C++ Logo

std-discussion

Advanced search

Re: Addressability of the standard template function std::invoke.

From: Simon Kraemer <sikraemer_at_[hidden]>
Date: Mon, 30 Oct 2023 08:19:07 +0100
Isn't that what std::mem_fn is for?
```
std::for_each( std::begin( v ), std::end( v ),
std::mem_fn(&std::function<void()>::operator()) );
```

Am So., 29. Okt. 2023 um 01:53 Uhr schrieb Marcin Jaczewski via
Std-Discussion <std-discussion_at_[hidden]>:

> sob., 28 paź 2023 o 19:50 Ville Voutilainen via Std-Discussion
> <std-discussion_at_[hidden]> napisał(a):
> >
> > On Sat, 28 Oct 2023 at 20:31, Daniel Krügler via Std-Discussion
> > <std-discussion_at_[hidden]> wrote:
> >
> > > > std::for_each( std::begin( v ), std::end( v ),
> std::invoke<std::function<void()> &> );
> > >
> > > Why not using a lambda expression instead?
> >
> > Because this way of writing it clearly and concisely says that it's a
> > currying operation that constrains the type
> > of the operand of the curried function. For a lambda, you need to read
> > its whole definition to figure out whether it's doing
> > the equivalent of this operation.
> >
> > Vladimir, just write your own wrapping function (template) that does
> > what you want, and pass the address of that.
>
> Could standard support it but using `bind`?, like:
> ```
> std::bind(std::placeholders::_1)
> ```
> Right now it's not compiling but in theory could be allowed too.
>
> > --
> > Std-Discussion mailing list
> > Std-Discussion_at_[hidden]
> > https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
> --
> Std-Discussion mailing list
> Std-Discussion_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion
>

Received on 2023-10-30 07:19:20