Namespaces
Variants
Views
Actions

std::experimental::ranges::invoke

From cppreference.com
< cpp‎ | experimental‎ | ranges
 
 
Experimental
Technical Specification
Filesystem library (filesystem TS)
Library fundamentals (library fundamentals TS)
Library fundamentals 2 (library fundamentals TS v2)
Library fundamentals 3 (library fundamentals TS v3)
Extensions for parallelism (parallelism TS)
Extensions for parallelism 2 (parallelism TS v2)
Extensions for concurrency (concurrency TS)
Extensions for concurrency 2 (concurrency TS v2)
Concepts (concepts TS)
Ranges (ranges TS)
Reflection (reflection TS)
Mathematical special functions (special functions TR)
Experimental Non-TS
Pattern Matching
Linear Algebra
std::execution
Contracts
2D Graphics
 
 
General utilities library
Utility components
Function objects
invoke
Metaprogramming and type traits
Tagged pairs and tuples
                          
tag specifiers
                                      
                          
 
template< class F, class... Args >
std::result_of_t<F&&(Args&&...)> invoke( F&& f, Args&&... args );
(ranges TS)

Invoke the Callable object f with the parameters args, and return the result, as if by return INVOKE(std::forward<F>(f), std::forward<Args>(args)...);, where INVOKE(f, t1, t2, ..., tN) is defined as follows:

  • If std::is_base_of<T, std::decay_t<decltype(t1)>>::value is true, then INVOKE(f, t1, t2, ..., tN) is equivalent to (t1.*f)(t2, ..., tN),
  • otherwise, INVOKE(f, t1, t2, ..., tN) is equivalent to ((*t1).*f)(t2, ..., tN).
  • If std::is_base_of<T, std::decay_t<decltype(t1)>>::value is true, then INVOKE(f, t1) is equivalent to t1.*f,
  • otherwise, then INVOKE(f, t1) is equivalent to (*t1).*f.
  • otherwise, INVOKE(f, t1, t2, ..., tN) is equivalent to f(t1, t2, ..., tN) (that is, f is a FunctionObject).

[edit] Parameters

f - Callable object to be invoked
args - arguments to pass to f

[edit] See also

(C++17)(C++23)
invokes any Callable object with given arguments and possibility to specify return type(since C++23)
(function template) [edit]