folly::invoke_noreturn_cold

invoke_noreturn_cold

Synopsis

Declared in <folly/lang/Exception.h>

template<
    typename F,
    typename... A>
[[noreturn]]
void
invoke_noreturn_cold(
    F&& f,
    A&&... a) noexcept(/* see-below */);

Description

Invoke the provided function with the provided arguments. If the invocation returns, terminate.

May be used with throw_exception in cases where construction of the object to be thrown requires more than just invoking its constructor with a given sequence of arguments passed by reference - for example, if a string message must be computed before being passed to the constructor of the object to be thrown.

Usage note: Passing extra values as arguments rather than capturing them allows smaller inlined native code at the call-site.

Example:

if (i < 0) { invoke_noreturn_cold( []j) { throw_exceptions(runtime_error(to<string>("invalid: ", j))); }, i); }

Exception specification

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

Return Value

NOTE

This function does not return.

Parameters

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