template <typename R, typename... Args>
class FunctionRef
Defined at line 87 of file ../../third_party/abseil-cpp/src/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);
Public Methods
template <typename F, typename = EnableIfCompatible<std::enable_if_t< !std::is_same_v<FunctionRef, absl::remove_cvref_t<F>>, F&>>>
void FunctionRef<R (Args...)> (F && f)
NOLINTNEXTLINE(google-explicit-constructor)
Defined at line 111 of file ../../third_party/abseil-cpp/src/absl/functional/function_ref.h
template <typename F,typename = EnableIfCompatible<F*>,absl::functional_internal::EnableIf<std::is_function_v<F>> = 0>
void FunctionRef<R (Args...)> (F * f)
NOLINTNEXTLINE(google-explicit-constructor)
Defined at line 123 of file ../../third_party/abseil-cpp/src/absl/functional/function_ref.h
template <auto F, typename = EnableIfCompatible<decltype(F)>>
void FunctionRef<R (Args...)> (nontype_t<F> )
Similar to the other overloads, but passes the address of a known callable
`F` at compile time. This allows calling arbitrary functions while avoiding
an indirection.
Needs C++20 as `nontype_t` needs C++20 for `auto` template parameters.
Defined at line 135 of file ../../third_party/abseil-cpp/src/absl/functional/function_ref.h
template <auto F,typename Obj,typename = EnableIfCompatible<decltype(F), std::remove_reference_t<Obj>&>,absl::functional_internal::EnableIf<!std::is_rvalue_reference_v<Obj&&>> = 0>
void FunctionRef<R (Args...)> (nontype_t<F> , Obj && obj)
NOLINTNEXTLINE(google-explicit-constructor)
Defined at line 145 of file ../../third_party/abseil-cpp/src/absl/functional/function_ref.h
template <auto F,typename Obj,typename = EnableIfCompatible<decltype(F), std::remove_reference_t<Obj>&>,absl::functional_internal::EnableIf<!std::is_rvalue_reference_v<Obj&&>> = 0>
void FunctionRef<R (Args...)> (nontype_t<F> , Obj && obj)
NOLINTNEXTLINE(google-explicit-constructor)
Defined at line 145 of file ../../third_party/abseil-cpp/src/absl/functional/function_ref.h
template <auto F,typename Obj,typename = EnableIfCompatible<decltype(F), Obj*>>
void FunctionRef<R (Args...)> (nontype_t<F> , Obj * obj)
NOLINTNEXTLINE(google-explicit-constructor)
Defined at line 154 of file ../../third_party/abseil-cpp/src/absl/functional/function_ref.h
R operator() (Args... args)
Call the underlying object.
Defined at line 164 of file ../../third_party/abseil-cpp/src/absl/functional/function_ref.h
template <typename F, typename = EnableIfCompatible<std::enable_if_t< !std::is_same_v<FunctionRef, absl::remove_cvref_t<F>>, const F&>>>
void FunctionRef<R (Args...) const> (const F & f)
NOLINTNEXTLINE(google-explicit-constructor)
Defined at line 190 of file ../../third_party/abseil-cpp/src/absl/functional/function_ref.h
template <auto F,typename Obj,typename = EnableIfCompatible<decltype(F), const Obj*>>
void FunctionRef<R (Args...) const> (nontype_t<F> arg, const Obj * obj)
NOLINTNEXTLINE(google-explicit-constructor)
Defined at line 216 of file ../../third_party/abseil-cpp/src/absl/functional/function_ref.h
Protected Methods
template <typename F>
void FunctionRef<R (Args...)> (std::in_place_t , F && f)
NOLINTNEXTLINE(google-explicit-constructor)
Defined at line 99 of file ../../third_party/abseil-cpp/src/absl/functional/function_ref.h