C++ Logo

std-discussion

Advanced search

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

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Sun, 29 Oct 2023 01:52:59 +0200
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

Received on 2023-10-28 23:53:12