template <typename R, typename... Args>
class FunctionRef
Defined at line 89 of file ../../third_party/abseil-cpp/absl/functional/function_ref.h
FunctionRef
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);
Note: the assignment operator within an `absl::FunctionRef` is intentionally
deleted to prevent misuse; because the `absl::FunctionRef` does not own the
underlying type, assignment likely indicates misuse.
Public Methods
template <typename F, typename = EnableIfCompatible<const F&>>
void FunctionRef<R (Args...)> (const F & f)
NOLINTNEXTLINE(runtime/explicit)
Defined at line 104 of file ../../third_party/abseil-cpp/absl/functional/function_ref.h
template <typename F, typename = EnableIfCompatible<F*>, absl::functional_internal::EnableIf<absl::is_function<F>::value> = 0>
void FunctionRef<R (Args...)> (F * f)
Overload for function pointers. This eliminates a level of indirection that
would happen if the above overload was used (it lets us store the pointer
instead of a pointer to a pointer).
This overload is also used for references to functions, since references to
functions can decay to function pointers implicitly.
Defined at line 119 of file ../../third_party/abseil-cpp/absl/functional/function_ref.h
FunctionRef<R (Args...)> & operator= (const FunctionRef<R (Args...)> & rhs)
To help prevent subtle lifetime bugs, FunctionRef is not assignable.
Typically, it should only be used as an argument type.
Defined at line 127 of file ../../third_party/abseil-cpp/absl/functional/function_ref.h
void FunctionRef<R (Args...)> (const FunctionRef<R (Args...)> & rhs)
Defined at line 128 of file ../../third_party/abseil-cpp/absl/functional/function_ref.h
R operator() (Args... args)
Call the underlying object.
Defined at line 131 of file ../../third_party/abseil-cpp/absl/functional/function_ref.h