KiCad PCB EDA Suite
Loading...
Searching...
No Matches
INPLACE_FUNCTION< R(Args...), Capacity > Class Template Reference

#include <inplace_function.h>

Public Member Functions

 INPLACE_FUNCTION ()=default
 
template<typename F, typename = std::enable_if_t< !std::is_same_v<std::decay_t<F>, INPLACE_FUNCTION> && std::is_invocable_r_v<R, const std::decay_t<F>&, Args...>>>
 INPLACE_FUNCTION (F &&aCallable)
 
 INPLACE_FUNCTION (const INPLACE_FUNCTION &aOther)
 
 INPLACE_FUNCTION (INPLACE_FUNCTION &&aOther) noexcept
 
INPLACE_FUNCTIONoperator= (const INPLACE_FUNCTION &aOther)
 
INPLACE_FUNCTIONoperator= (INPLACE_FUNCTION &&aOther) noexcept
 
template<typename F, typename = std::enable_if_t< !std::is_same_v<std::decay_t<F>, INPLACE_FUNCTION> && std::is_invocable_r_v<R, const std::decay_t<F>&, Args...>>>
INPLACE_FUNCTIONoperator= (F &&aCallable)
 
 ~INPLACE_FUNCTION ()
 
 operator bool () const
 
operator() (Args... aArgs) const
 

Private Types

enum class  OP { DESTROY , MOVE , COPY }
 
using INVOKE_FN = R ( * )( const void*, Args&&... )
 
using MANAGE_FN = void ( * )( OP, void*, const void* )
 

Private Member Functions

template<typename F>
void assign (F &&aCallable)
 
void reset ()
 
void moveFrom (INPLACE_FUNCTION &aOther)
 
void copyFrom (const INPLACE_FUNCTION &aOther)
 

Private Attributes

unsigned char m_storage [Capacity]
 
INVOKE_FN m_invoke = nullptr
 
MANAGE_FN m_manage = nullptr
 

Detailed Description

template<typename R, typename... Args, std::size_t Capacity>
class INPLACE_FUNCTION< R(Args...), Capacity >

Definition at line 45 of file inplace_function.h.

Member Typedef Documentation

◆ INVOKE_FN

template<typename R, typename... Args, std::size_t Capacity>
using INPLACE_FUNCTION< R(Args...), Capacity >::INVOKE_FN = R ( * )( const void*, Args&&... )
private

Definition at line 114 of file inplace_function.h.

◆ MANAGE_FN

template<typename R, typename... Args, std::size_t Capacity>
using INPLACE_FUNCTION< R(Args...), Capacity >::MANAGE_FN = void ( * )( OP, void*, const void* )
private

Definition at line 115 of file inplace_function.h.

Member Enumeration Documentation

◆ OP

template<typename R, typename... Args, std::size_t Capacity>
enum class INPLACE_FUNCTION< R(Args...), Capacity >::OP
strongprivate
Enumerator
DESTROY 
MOVE 
COPY 

Definition at line 112 of file inplace_function.h.

Constructor & Destructor Documentation

◆ INPLACE_FUNCTION() [1/4]

template<typename R, typename... Args, std::size_t Capacity>
INPLACE_FUNCTION< R(Args...), Capacity >::INPLACE_FUNCTION ( )
default

◆ INPLACE_FUNCTION() [2/4]

template<typename R, typename... Args, std::size_t Capacity>
template<typename F, typename = std::enable_if_t< !std::is_same_v<std::decay_t<F>, INPLACE_FUNCTION> && std::is_invocable_r_v<R, const std::decay_t<F>&, Args...>>>
INPLACE_FUNCTION< R(Args...), Capacity >::INPLACE_FUNCTION ( F && aCallable)
inline

Definition at line 54 of file inplace_function.h.

References assign(), and F.

◆ INPLACE_FUNCTION() [3/4]

template<typename R, typename... Args, std::size_t Capacity>
INPLACE_FUNCTION< R(Args...), Capacity >::INPLACE_FUNCTION ( const INPLACE_FUNCTION< R(Args...), Capacity > & aOther)
inline

Definition at line 59 of file inplace_function.h.

References copyFrom(), and INPLACE_FUNCTION().

◆ INPLACE_FUNCTION() [4/4]

template<typename R, typename... Args, std::size_t Capacity>
INPLACE_FUNCTION< R(Args...), Capacity >::INPLACE_FUNCTION ( INPLACE_FUNCTION< R(Args...), Capacity > && aOther)
inlinenoexcept

Definition at line 60 of file inplace_function.h.

References INPLACE_FUNCTION(), and moveFrom().

◆ ~INPLACE_FUNCTION()

template<typename R, typename... Args, std::size_t Capacity>
INPLACE_FUNCTION< R(Args...), Capacity >::~INPLACE_FUNCTION ( )
inline

Definition at line 99 of file inplace_function.h.

References reset().

Member Function Documentation

◆ assign()

template<typename R, typename... Args, std::size_t Capacity>
template<typename F>
void INPLACE_FUNCTION< R(Args...), Capacity >::assign ( F && aCallable)
inlineprivate

Definition at line 118 of file inplace_function.h.

References COPY, DESTROY, F, m_invoke, m_manage, m_storage, and MOVE.

Referenced by INPLACE_FUNCTION().

◆ copyFrom()

template<typename R, typename... Args, std::size_t Capacity>
void INPLACE_FUNCTION< R(Args...), Capacity >::copyFrom ( const INPLACE_FUNCTION< R(Args...), Capacity > & aOther)
inlineprivate

Definition at line 174 of file inplace_function.h.

References COPY, INPLACE_FUNCTION(), m_invoke, m_manage, and m_storage.

Referenced by INPLACE_FUNCTION().

◆ moveFrom()

template<typename R, typename... Args, std::size_t Capacity>
void INPLACE_FUNCTION< R(Args...), Capacity >::moveFrom ( INPLACE_FUNCTION< R(Args...), Capacity > & aOther)
inlineprivate

Definition at line 161 of file inplace_function.h.

References INPLACE_FUNCTION(), m_invoke, m_manage, m_storage, and MOVE.

Referenced by INPLACE_FUNCTION(), operator=(), operator=(), and operator=().

◆ operator bool()

template<typename R, typename... Args, std::size_t Capacity>
INPLACE_FUNCTION< R(Args...), Capacity >::operator bool ( ) const
inlineexplicit

Definition at line 101 of file inplace_function.h.

References m_invoke.

◆ operator()()

template<typename R, typename... Args, std::size_t Capacity>
R INPLACE_FUNCTION< R(Args...), Capacity >::operator() ( Args... aArgs) const
inline

Definition at line 103 of file inplace_function.h.

References m_invoke, and m_storage.

◆ operator=() [1/3]

template<typename R, typename... Args, std::size_t Capacity>
INPLACE_FUNCTION & INPLACE_FUNCTION< R(Args...), Capacity >::operator= ( const INPLACE_FUNCTION< R(Args...), Capacity > & aOther)
inline

Definition at line 62 of file inplace_function.h.

References INPLACE_FUNCTION(), moveFrom(), and reset().

◆ operator=() [2/3]

template<typename R, typename... Args, std::size_t Capacity>
template<typename F, typename = std::enable_if_t< !std::is_same_v<std::decay_t<F>, INPLACE_FUNCTION> && std::is_invocable_r_v<R, const std::decay_t<F>&, Args...>>>
INPLACE_FUNCTION & INPLACE_FUNCTION< R(Args...), Capacity >::operator= ( F && aCallable)
inline

Definition at line 91 of file inplace_function.h.

References F, INPLACE_FUNCTION(), moveFrom(), and reset().

◆ operator=() [3/3]

template<typename R, typename... Args, std::size_t Capacity>
INPLACE_FUNCTION & INPLACE_FUNCTION< R(Args...), Capacity >::operator= ( INPLACE_FUNCTION< R(Args...), Capacity > && aOther)
inlinenoexcept

Definition at line 76 of file inplace_function.h.

References INPLACE_FUNCTION(), moveFrom(), and reset().

◆ reset()

template<typename R, typename... Args, std::size_t Capacity>
void INPLACE_FUNCTION< R(Args...), Capacity >::reset ( )
inlineprivate

Definition at line 151 of file inplace_function.h.

References DESTROY, m_invoke, m_manage, and m_storage.

Referenced by operator=(), operator=(), operator=(), and ~INPLACE_FUNCTION().

Member Data Documentation

◆ m_invoke

template<typename R, typename... Args, std::size_t Capacity>
INVOKE_FN INPLACE_FUNCTION< R(Args...), Capacity >::m_invoke = nullptr
private

Definition at line 185 of file inplace_function.h.

Referenced by assign(), copyFrom(), moveFrom(), operator bool(), operator()(), and reset().

◆ m_manage

template<typename R, typename... Args, std::size_t Capacity>
MANAGE_FN INPLACE_FUNCTION< R(Args...), Capacity >::m_manage = nullptr
private

Definition at line 186 of file inplace_function.h.

Referenced by assign(), copyFrom(), moveFrom(), and reset().

◆ m_storage

template<typename R, typename... Args, std::size_t Capacity>
unsigned char INPLACE_FUNCTION< R(Args...), Capacity >::m_storage[Capacity]
private

Definition at line 184 of file inplace_function.h.

Referenced by assign(), copyFrom(), moveFrom(), operator()(), and reset().


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