invoke_cold
Declared in <folly/lang/Exception.h>
template<
typename F,
typename... A,
typename FD = std::remove_pointer_t<std::decay_t<F>>,
typename R = decltype(FOLLY_DECLVAL(F&&)(FOLLY_DECLVAL(A&&)...))>
requires !std::is_function<FD>::value
R
invoke_cold(
F&& f,
A&&... a) noexcept(/* see-below */);
Invoke the provided function with the provided arguments.
Usage note: Passing extra values as arguments rather than capturing them allows smaller inlined native code at the call-site. Passing function-pointers or function- references rather than general callables with captures allows allows smaller inlined native code at the call-site as well.
Example:
if (i < 0) { invoke_cold( []j) { std::string ret = doStepA(); doStepB(ret); doStepC(ret); }, i); }
This function is potentially-throwing unless noexcept(static_cast<F &&>(f)(static_cast<A &&>(a)...)).
The result of invoking the function with the arguments.
| Name | Description |
|---|---|
| f | The function to invoke. |
| a | The arguments to forward to the function. |