proxygen
folly::detail::function Namespace Reference

Classes

struct  CoerceTag
 
union  Data
 
struct  FunctionTraits
 
struct  FunctionTraits< ReturnType(Args...) const >
 
struct  FunctionTraits< ReturnType(Args...)>
 
struct  NotFunction
 
struct  NotFunction< Function< T > >
 

Typedefs

template<typename Fun , typename = Fun*>
using IsSmall = Conjunction< bool_constant<(sizeof(Fun)<=sizeof(Data::tiny))>, std::is_nothrow_move_constructible< Fun >>
 
using SmallTag = std::true_type
 
using HeapTag = std::false_type
 
template<typename T >
using EnableIfNotFunction = typename std::enable_if< NotFunction< T >::value >::type
 
template<typename F , typename... Args>
using CallableResult = decltype(std::declval< F >()(std::declval< Args >()...))
 
template<typename From , typename To , typename = typename std::enable_if< !std::is_reference<To>::value || std::is_reference<From>::value>::type>
using SafeResultOf = decltype(static_cast< To >(std::declval< From >()))
 

Enumerations

enum  Op { Op::MOVE, Op::NUKE, Op::HEAP }
 

Functions

template<typename T >
bool isNullPtrFn (T *p)
 
template<typename T >
std::false_type isNullPtrFn (T &&)
 
template<typename Fun >
bool execSmall (Op o, Data *src, Data *dst)
 
template<typename Fun >
bool execBig (Op o, Data *src, Data *dst)
 

Typedef Documentation

template<typename F , typename... Args>
using folly::detail::function::CallableResult = typedef decltype(std::declval<F>()(std::declval<Args>()...))

Definition at line 286 of file Function.h.

template<typename T >
using folly::detail::function::EnableIfNotFunction = typedef typename std::enable_if<NotFunction<T>::value>::type

Definition at line 272 of file Function.h.

using folly::detail::function::HeapTag = typedef std::false_type

Definition at line 263 of file Function.h.

template<typename Fun , typename = Fun*>
using folly::detail::function::IsSmall = typedef Conjunction< bool_constant<(sizeof(Fun) <= sizeof(Data::tiny))>, std::is_nothrow_move_constructible<Fun>>

Definition at line 261 of file Function.h.

template<typename From , typename To , typename = typename std::enable_if< !std::is_reference<To>::value || std::is_reference<From>::value>::type>
using folly::detail::function::SafeResultOf = typedef decltype(static_cast<To>(std::declval<From>()))

Definition at line 293 of file Function.h.

using folly::detail::function::SmallTag = typedef std::true_type

Definition at line 262 of file Function.h.

Enumeration Type Documentation

Function Documentation

template<typename Fun >
bool folly::detail::function::execBig ( Op  o,
Data src,
Data dst 
)

Definition at line 499 of file Function.h.

References folly::detail::function::Data::big, HEAP, MOVE, and NUKE.

499  {
500  switch (o) {
501  case Op::MOVE:
502  dst->big = src->big;
503  src->big = nullptr;
504  break;
505  case Op::NUKE:
506  delete static_cast<Fun*>(src->big);
507  break;
508  case Op::HEAP:
509  break;
510  }
511  return true;
512 }
template<typename Fun >
bool folly::detail::function::execSmall ( Op  o,
Data src,
Data dst 
)

Definition at line 483 of file Function.h.

References FOLLY_FALLTHROUGH, HEAP, MOVE, folly::gen::move, NUKE, and folly::detail::function::Data::tiny.

483  {
484  switch (o) {
485  case Op::MOVE:
486  ::new (static_cast<void*>(&dst->tiny))
487  Fun(std::move(*static_cast<Fun*>(static_cast<void*>(&src->tiny))));
489  case Op::NUKE:
490  static_cast<Fun*>(static_cast<void*>(&src->tiny))->~Fun();
491  break;
492  case Op::HEAP:
493  break;
494  }
495  return false;
496 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
STL namespace.
#define FOLLY_FALLTHROUGH
Definition: CppAttributes.h:63
template<typename T >
bool folly::detail::function::isNullPtrFn ( T p)

Definition at line 277 of file Function.h.

Referenced by folly::Function< std::vector< ResultT >(std::vector< InputT > &&)>::Function().

277  {
278  return p == nullptr;
279 }
template<typename T >
std::false_type folly::detail::function::isNullPtrFn ( T &&  )

Definition at line 281 of file Function.h.

References testing::Args().

281  {
282  return {};
283 }