May 2017
Intermediate to advanced
590 pages
17h 18m
English
The std::invoke() function is a variadic function template that takes the callable object as the first argument and a variable list of arguments that are passed to the call. std::invoke() can be used to call the following:
auto a1 = std::invoke(add, 1, 2); // a1 = 3
auto a2 = std::invoke(&add, 1, 2); // a2 = 3 int(*fadd)(int const, int const) = &add; auto a3 = std::invoke(fadd, 1, 2); // a3 = 3
foo f; std::invoke(&foo::increment_by, f, 10);
foo f; auto x1 = std::invoke(&foo::x, f); // x1 = 0
foo f; auto x3 = std::invoke(std::plus<>(), std::invoke(&foo::x, ...Read now
Unlock full access