Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::util::SmallFunc Class Reference

Move-only function wrapper with inline storage and optional SmallBlockAllocator spill storage. Medium spill storage uses SmallBlockAllocator when GAIA_FUNC_WRAPPER_SMALLBLOCK is enabled. More...

#include <small_func.h>

Public Member Functions

 SmallFunc ()=default
 Constructs an empty function wrapper.
 
 ~SmallFunc ()
 Destroys the stored callable, if any.
 
 SmallFunc (const SmallFunc &)=delete
 
SmallFuncoperator= (const SmallFunc &)=delete
 
 SmallFunc (SmallFunc &&other) noexcept
 Move-constructs the wrapper.
 
SmallFuncoperator= (SmallFunc &&other) noexcept
 Move-assigns the wrapper.
 
template<typename F , typename = std::enable_if_t<!std::is_same_v<std::decay_t<F>, SmallFunc>>>
 SmallFunc (F &&f)
 
template<typename F , typename = std::enable_if_t<!std::is_same_v<std::decay_t<F>, SmallFunc>>>
SmallFuncoperator= (F &&f)
 
void exec ()
 Executes the stored callable.
 
void operator() ()
 Executes the stored callable.
 
void reset ()
 Clears the wrapper.
 
 operator bool () const
 Returns true when a callable is stored.
 

Static Public Member Functions

template<typename F >
static SmallFunc create (F &&f)
 Creates a wrapper from a callable compatible with void().
 
static void destroy (SmallFunc &func)
 Destroys the callable held by the wrapper.
 

Detailed Description

Move-only function wrapper with inline storage and optional SmallBlockAllocator spill storage. Medium spill storage uses SmallBlockAllocator when GAIA_FUNC_WRAPPER_SMALLBLOCK is enabled.

Constructor & Destructor Documentation

◆ SmallFunc()

gaia::util::SmallFunc::SmallFunc ( SmallFunc &&  other)
inlinenoexcept

Move-constructs the wrapper.

Parameters
otherSource wrapper.

Member Function Documentation

◆ create()

template<typename F >
static SmallFunc gaia::util::SmallFunc::create ( F &&  f)
inlinestatic

Creates a wrapper from a callable compatible with void().

Template Parameters
FCallable type.
Parameters
fCallable object.
Returns
New function wrapper.

◆ destroy()

static void gaia::util::SmallFunc::destroy ( SmallFunc func)
inlinestatic

Destroys the callable held by the wrapper.

Parameters
funcWrapper to clear.

◆ operator=()

SmallFunc & gaia::util::SmallFunc::operator= ( SmallFunc &&  other)
inlinenoexcept

Move-assigns the wrapper.

Parameters
otherSource wrapper.
Returns
Reference to this wrapper.

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