folly::invoke_cold

invoke_cold

Synopsis

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 */);

Description

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); }

Exception specification

This function is potentially-throwing unless noexcept(static_cast<F &&>(f)(static_cast<A &&>(a)...)).

Return Value

The result of invoking the function with the arguments.

Parameters

NameDescription
fThe function to invoke.
aThe arguments to forward to the function.