C++ Logo

std-discussion

Advanced search

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

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Sat, 28 Oct 2023 20:49:54 +0300
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.

Received on 2023-10-28 17:50:07