proxygen
folly::FunctionRef< ReturnType(Args...)> Class Template Referencefinal

#include <Function.h>

Public Member Functions

 FunctionRef ()=default
 
template<typename Fun , typename std::enable_if< Conjunction< Negation< std::is_same< FunctionRef, _t< std::decay< Fun >>>>, is_invocable_r< ReturnType, Fun &&, Args &&... >>::value, int >::type = 0>
constexpr FunctionRef (Fun &&fun) noexcept
 
ReturnType operator() (Args...args) const
 
constexpr operator bool () const
 

Private Types

using Call = ReturnType(*)(void *, Args &&...)
 

Static Private Member Functions

static ReturnType uninitCall (void *, Args &&...)
 
template<typename Fun >
static ReturnType call (void *object, Args &&...args)
 

Private Attributes

void * object_ {nullptr}
 
Call call_ {&FunctionRef::uninitCall}
 

Detailed Description

template<typename ReturnType, typename... Args>
class folly::FunctionRef< ReturnType(Args...)>

Definition at line 896 of file Function.h.

Member Typedef Documentation

template<typename ReturnType , typename... Args>
using folly::FunctionRef< ReturnType(Args...)>::Call = ReturnType (*)(void*, Args&&...)
private

Definition at line 897 of file Function.h.

Constructor & Destructor Documentation

template<typename ReturnType , typename... Args>
folly::FunctionRef< ReturnType(Args...)>::FunctionRef ( )
default

Default constructor. Constructs an empty FunctionRef.

Invoking it will throw std::bad_function_call.

template<typename ReturnType , typename... Args>
template<typename Fun , typename std::enable_if< Conjunction< Negation< std::is_same< FunctionRef, _t< std::decay< Fun >>>>, is_invocable_r< ReturnType, Fun &&, Args &&... >>::value, int >::type = 0>
constexpr folly::FunctionRef< ReturnType(Args...)>::FunctionRef ( Fun &&  fun)
inlinenoexcept

Construct a FunctionRef from a reference to a callable object.

Definition at line 932 of file Function.h.

937  : object_(
938  const_cast<void*>(static_cast<void const*>(std::addressof(fun)))),
939  call_(&FunctionRef::call<Fun>) {}
void fun()

Member Function Documentation

template<typename ReturnType , typename... Args>
template<typename Fun >
static ReturnType folly::FunctionRef< ReturnType(Args...)>::call ( void *  object,
Args &&...  args 
)
inlinestaticprivate

Definition at line 904 of file Function.h.

References folly::invoke().

904  {
905  using Pointer = _t<std::add_pointer<Fun>>;
906  return static_cast<ReturnType>(invoke(
907  static_cast<Fun&&>(*static_cast<Pointer>(object)),
908  static_cast<Args&&>(args)...));
909  }
constexpr auto invoke(F &&f, Args &&...args) noexcept(noexcept(static_cast< F && >(f)(static_cast< Args && >(args)...))) -> decltype(static_cast< F && >(f)(static_cast< Args && >(args)...))
Definition: Invoke.h:49
template<typename ReturnType , typename... Args>
constexpr folly::FunctionRef< ReturnType(Args...)>::operator bool ( ) const
inlineexplicit

Definition at line 945 of file Function.h.

945  {
946  return object_;
947  }
template<typename ReturnType , typename... Args>
ReturnType folly::FunctionRef< ReturnType(Args...)>::operator() ( Args...  args) const
inline

Definition at line 941 of file Function.h.

941  {
942  return call_(object_, static_cast<Args&&>(args)...);
943  }
template<typename ReturnType , typename... Args>
static ReturnType folly::FunctionRef< ReturnType(Args...)>::uninitCall ( void *  ,
Args &&  ... 
)
inlinestaticprivate

Definition at line 899 of file Function.h.

899  {
900  throw std::bad_function_call();
901  }

Member Data Documentation

template<typename ReturnType , typename... Args>
Call folly::FunctionRef< ReturnType(Args...)>::call_ {&FunctionRef::uninitCall}
private

Definition at line 912 of file Function.h.

template<typename ReturnType , typename... Args>
void* folly::FunctionRef< ReturnType(Args...)>::object_ {nullptr}
private

Definition at line 911 of file Function.h.


The documentation for this class was generated from the following file: