| Defined in header <experimental/ranges/functional>
|
||
| 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
fis a pointer to member function of classT:
- If
std::is_base_of<T, std::decay_t<decltype(t1)>>::valueistrue, thenINVOKE(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
- otherwise, if N == 1 and
fis a pointer to data member of classT:
- If
std::is_base_of<T, std::decay_t<decltype(t1)>>::valueistrue, thenINVOKE(f, t1)is equivalent tot1.*f, - otherwise, then
INVOKE(f, t1)is equivalent to(*t1).*f.
- If
- otherwise,
INVOKE(f, t1, t2, ..., tN)is equivalent tof(t1, t2, ..., tN)(that is,fis a FunctionObject).
Parameters
| f | - | Callable object to be invoked |
| args | - | arguments to pass to f
|
See also
| (C++17)(C++23) |
invokes any Callable object with given arguments and possibility to specify return type(since C++23) (function template) |
Content from this page on cppreference.com, licensed under CC-BY-SA 3.0 and GFDL. Modified: restyled, site navigation removed, code windows added. Offline snapshot of 9 February 2025.