std::experi...nges::invoke(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– NAME πŸ’–

std::experimental::ranges::invoke β€” std::experimental::ranges::invoke

This one comes from the C++ Standard Libary manual (yes, β€œLibary” is literally how it’s spelled on the page, bestie πŸ’€). It’s giving β€œinvoke things correctly” energy, and honestly? Iconic.

✨ Synopsis ✨

Defined in header <experimental/ranges/functional>

template< class F, class... Args >
(ranges TS)
std::result_of_t<F&&(Args&&...)> invoke( F&& f, Args&&... args );

Okay so the vibe is: 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 f is a pointer to member function of class T:
    • 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).
  • otherwise, if N == 1 and f is a pointer to data member of class T:
    • 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).

πŸŽ€ Parameters πŸŽ€

  • f β€” Callable object to be invoked
  • args β€” arguments to pass to f

πŸ‘‘ See also πŸ‘‘

The See also block lists:

  • invoke β€” invokes any Callable object with given arguments
  • invoke_r and possibility to specify return type
  • the markers it carries: (C++17), (since C++23), (C++23), (function template)

Source/version/date sign-off: http://cppreference.com Β· 2024.06.10 Β· page std::experi...nges::invoke(3). Byeee, go invoke something cute πŸ«ΆπŸ’–

πŸ“¦ where this page comes from