A reference wrapper for callable objects
Synopsis
Declared in <folly/Function.h>
template<typename FunctionType>
class FunctionRef;
Description
FunctionRef is similar to std::reference_wrapper, but the template parameter is the function signature type rather than the type of the referenced object. A folly::FunctionRef is cheap to construct as it contains only a pointer to the referenced callable and a pointer to a function which invokes the callable.
The user of FunctionRef must be aware of the reference semantics: storing a copy of a FunctionRef is potentially dangerous and should be avoided unless the referenced object definitely outlives the FunctionRef object. Thus any function that accepts a FunctionRef parameter should only use it to invoke the referenced function and not store a copy of it. Knowing that FunctionRef itself has reference semantics, it is generally okay to use it to reference lambdas that capture by reference.
Specializations
Non-Member Functions
Name |
Description |
Apply |
Created with MrDocs