absl::FunctionRef<R const(Args...)>

FunctionRef

Synopsis

Declared in <absl/functional/function_ref.h>

template<
    typename R,
    typename... Args>
class FunctionRef<R const(Args...)>;

Description

An absl::FunctionRef is a lightweight wrapper to any invocable object with a compatible signature. Generally, an absl::FunctionRef should only be used as an argument type and should be preferred as an argument over a const reference to a std::function. absl::FunctionRef itself does not allocate, although the wrapped invocable may.

Example:

// The following function takes a function callback by const reference bool Visitor(const std::function<void(my_proto&, absl::string_view)>& callback);

// Assuming that the function is not stored or otherwise copied, it can be // replaced by an absl::FunctionRef: bool Visitor(absl::FunctionRef<void(my_proto&, absl::string_view)> callback);

Type Aliases

Name
absl_internal_is_view

Member Functions

NameDescription
FunctionRef [constructor]Constructors
operator()

Using Declarations

Name
operator()

Protected Type Aliases

Name
EnableIfCompatible

Protected Member Functions

Name
FunctionRef [constructor]