When to use std::invoke instead of simply calling the invokable?

If the invocable is a pointer to a member function, then you need to do one of these:

(arg1->*f)(arg2,...);
(arg1.*f)(arg2,...);

Depending on what arg1 is.

INVOKE (and its official library counterpart std::invoke) was pretty much designed to simplify such messes.

You’d use std::invoke to support the caller of your code passing any callable, and not having to adapt their call site with a lambda or a call to std::bind.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)