WPILibC++ 2024.3.2
wpi::detail::UniqueFunctionBase< ReturnT, ParamTs > Class Template Reference

#include </home/runner/work/allwpilib/allwpilib/wpiutil/src/main/native/thirdparty/llvm/include/wpi/FunctionExtras.h>

Classes

struct  CallbacksHolder
 
struct  CallbacksHolder< CallableT, CalledAs, EnableIfTrivial< CallableT > >
 
struct  CalledAs
 
struct  IsSizeLessThanThresholdT
 

Public Member Functions

 operator bool () const
 

Protected Member Functions

NonTrivialCallbacks * getNonTrivialCallbacks () const
 
CallPtrT getCallPtr () const
 
void * getCalleePtr () const
 
void * getInlineStorage () const
 
void * getOutOfLineStorage () const
 
size_t getOutOfLineStorageSize () const
 
size_t getOutOfLineStorageAlignment () const
 
void setOutOfLineStorage (void *Ptr, size_t Size, size_t Alignment)
 
template<typename CallableT , typename CalledAsT >
 UniqueFunctionBase (CallableT Callable, CalledAs< CalledAsT >)
 
 ~UniqueFunctionBase ()
 
 UniqueFunctionBase (UniqueFunctionBase &&RHS) noexcept
 
UniqueFunctionBaseoperator= (UniqueFunctionBase &&RHS) noexcept
 
 UniqueFunctionBase ()=default
 

Static Protected Member Functions

template<typename CalledAsT >
static ReturnT CallImpl (void *CallableAddr, AdjustedParamT< ParamTs >... Params)
 
template<typename CallableT >
static void MoveImpl (void *LHSCallableAddr, void *RHSCallableAddr) noexcept
 
template<typename CallableT >
static void DestroyImpl (void *CallableAddr) noexcept
 

Protected Attributes

template<typename T >
struct IsSizeLessThanThresholdT< T, std::enable_if_t< sizeof(T)<=2 *sizeof(void *)> > :std::true_type {};template< typename T > struct AdjustedParamTBase { static_assert(!std::is_reference< T >::value, "references should be handled by template specialization");using type=std::conditional_t< std::is_trivially_copy_constructible< T >::value &&std::is_trivially_move_constructible< T >::value &&IsSizeLessThanThresholdT< T >::value, T, T & >;};template< typename T > struct AdjustedParamTBase< T & > { using type=T &;};template< typename T > struct AdjustedParamTBase< T && > { using type=T &;};template< typename T > using AdjustedParamT=typename AdjustedParamTBase< T >::type;using CallPtrT=ReturnT(*)(void *CallableAddr, AdjustedParamT< ParamTs >... Params);using MovePtrT=void(*)(void *LHSCallableAddr, void *RHSCallableAddr);using DestroyPtrT=void(*)(void *CallableAddr);struct alignas(8) TrivialCallback { CallPtrT CallPtr;};struct alignas(8) NonTrivialCallbacks { CallPtrT CallPtr;MovePtrT MovePtr;DestroyPtrT DestroyPtr;};using CallbackPointerUnionT=PointerUnion< TrivialCallback *, NonTrivialCallbacks * >;union StorageUnionT { struct OutOfLineStorageT { void *StoragePtr;size_t Size;size_t Alignment;} OutOfLineStorage;static_assert(sizeof(OutOfLineStorageT)<=InlineStorageSize, "Should always use all of the out-of-line storage for inline storage!");alignas(void *) mutable std::byte InlineStorage[InlineStorageSize];} StorageUnion;PointerIntPair< CallbackPointerUnionT, 1, bool > CallbackAndInlineFlag;bool isInlineStorage() const { return CallbackAndInlineFlag.getInt();} bool isTrivialCallback() const { return isa< TrivialCallback * >(CallbackAndInlineFlag.getPointer());} CallPtrT getTrivialCallback() const { return cast< TrivialCallback * >(CallbackAndInlineFlag.getPointer()) -> CallPtr
 

Static Protected Attributes

static constexpr size_t InlineStorageSize = sizeof(void *) * 4
 

Constructor & Destructor Documentation

◆ UniqueFunctionBase() [1/3]

template<typename ReturnT , typename... ParamTs>
template<typename CallableT , typename CalledAsT >
wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::UniqueFunctionBase ( CallableT  Callable,
CalledAs< CalledAsT >   
)
inlineprotected

◆ ~UniqueFunctionBase()

template<typename ReturnT , typename... ParamTs>
wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::~UniqueFunctionBase ( )
inlineprotected

◆ UniqueFunctionBase() [2/3]

template<typename ReturnT , typename... ParamTs>
wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::UniqueFunctionBase ( UniqueFunctionBase< ReturnT, ParamTs > &&  RHS)
inlineprotectednoexcept

◆ UniqueFunctionBase() [3/3]

template<typename ReturnT , typename... ParamTs>
wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::UniqueFunctionBase ( )
protecteddefault

Member Function Documentation

◆ CallImpl()

template<typename ReturnT , typename... ParamTs>
template<typename CalledAsT >
static ReturnT wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::CallImpl ( void *  CallableAddr,
AdjustedParamT< ParamTs >...  Params 
)
inlinestaticprotected

◆ DestroyImpl()

template<typename ReturnT , typename... ParamTs>
template<typename CallableT >
static void wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::DestroyImpl ( void *  CallableAddr)
inlinestaticprotectednoexcept

◆ getCalleePtr()

template<typename ReturnT , typename... ParamTs>
void * wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::getCalleePtr ( ) const
inlineprotected

◆ getCallPtr()

template<typename ReturnT , typename... ParamTs>
CallPtrT wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::getCallPtr ( ) const
inlineprotected

◆ getInlineStorage()

template<typename ReturnT , typename... ParamTs>
void * wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::getInlineStorage ( ) const
inlineprotected

◆ getNonTrivialCallbacks()

template<typename ReturnT , typename... ParamTs>
NonTrivialCallbacks * wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::getNonTrivialCallbacks ( ) const
inlineprotected

◆ getOutOfLineStorage()

template<typename ReturnT , typename... ParamTs>
void * wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::getOutOfLineStorage ( ) const
inlineprotected

◆ getOutOfLineStorageAlignment()

template<typename ReturnT , typename... ParamTs>
size_t wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::getOutOfLineStorageAlignment ( ) const
inlineprotected

◆ getOutOfLineStorageSize()

template<typename ReturnT , typename... ParamTs>
size_t wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::getOutOfLineStorageSize ( ) const
inlineprotected

◆ MoveImpl()

template<typename ReturnT , typename... ParamTs>
template<typename CallableT >
static void wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::MoveImpl ( void *  LHSCallableAddr,
void *  RHSCallableAddr 
)
inlinestaticprotectednoexcept

◆ operator bool()

template<typename ReturnT , typename... ParamTs>
wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::operator bool ( ) const
inlineexplicit

◆ operator=()

template<typename ReturnT , typename... ParamTs>
UniqueFunctionBase & wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::operator= ( UniqueFunctionBase< ReturnT, ParamTs > &&  RHS)
inlineprotectednoexcept

◆ setOutOfLineStorage()

template<typename ReturnT , typename... ParamTs>
void wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::setOutOfLineStorage ( void *  Ptr,
size_t  Size,
size_t  Alignment 
)
inlineprotected

Member Data Documentation

◆ CallPtr

template<typename ReturnT , typename... ParamTs>
template<typename T >
struct IsSizeLessThanThresholdT< T, std::enable_if_t< sizeof(T)<=2 *sizeof(void *)> > :std::true_type {}; template< typename T > struct AdjustedParamTBase { static_assert(!std::is_reference< T >::value, "references should be handled by template specialization"); using type= std::conditional_t< std::is_trivially_copy_constructible< T >::value && std::is_trivially_move_constructible< T >::value && IsSizeLessThanThresholdT< T >::value, T, T & >; }; template< typename T > struct AdjustedParamTBase< T & > { using type=T &;}; template< typename T > struct AdjustedParamTBase< T && > { using type=T &;}; template< typename T > using AdjustedParamT=typename AdjustedParamTBase< T >::type; using CallPtrT=ReturnT(*)(void *CallableAddr, AdjustedParamT< ParamTs >... Params); using MovePtrT=void(*)(void *LHSCallableAddr, void *RHSCallableAddr); using DestroyPtrT=void(*)(void *CallableAddr); struct alignas(8) TrivialCallback { CallPtrT CallPtr; }; struct alignas(8) NonTrivialCallbacks { CallPtrT CallPtr; MovePtrT MovePtr; DestroyPtrT DestroyPtr; }; using CallbackPointerUnionT= PointerUnion< TrivialCallback *, NonTrivialCallbacks * >; union StorageUnionT { struct OutOfLineStorageT { void *StoragePtr; size_t Size; size_t Alignment; } OutOfLineStorage; static_assert( sizeof(OutOfLineStorageT)<=InlineStorageSize, "Should always use all of the out-of-line storage for inline storage!"); alignas(void *) mutable std::byte InlineStorage[InlineStorageSize]; } StorageUnion; PointerIntPair< CallbackPointerUnionT, 1, bool > CallbackAndInlineFlag; bool isInlineStorage() const { return CallbackAndInlineFlag.getInt();} bool isTrivialCallback() const { return isa< TrivialCallback * >(CallbackAndInlineFlag.getPointer()); } CallPtrT getTrivialCallback() const { return cast< TrivialCallback * >(CallbackAndInlineFlag.getPointer()) -> wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::CallPtr
protected

◆ InlineStorageSize

template<typename ReturnT , typename... ParamTs>
constexpr size_t wpi::detail::UniqueFunctionBase< ReturnT, ParamTs >::InlineStorageSize = sizeof(void *) * 4
staticconstexprprotected

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