jaulib v1.3.0
Jau Support Library (C++, Java, ..)
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | List of all members
jau::func::delegate_t< R, A > Class Template Referencefinal

Delegated target function object, providing a fast path target function invocation. More...

#include <functional.hpp>

Inheritance diagram for jau::func::delegate_t< R, A >:
Collaboration diagram for jau::func::delegate_t< R, A >:

Public Types

typedef int32_t size_type
 Utilize a reduced size type of int32_t. More...
 

Public Member Functions

 delegate_t (const delegate_t &o) noexcept
 
 delegate_t (delegate_t &&o) noexcept
 
 ~delegate_t () noexcept
 
constexpr size_t cached_size () const noexcept
 
template<typename T , typename... P>
template data ()
 
template<typename T , std::enable_if_t< std::is_trivially_copyable_v< T > &&sizeof(udata.cache) > = sizeof(T), bool >
std::enable_if_t<!std::is_trivially_copyable_v< T >||sizeof(udata.cache)< sizeof(T), bool >=true > constexpr const T * data () const noexcept
 
template<typename T , std::enable_if_t< std::is_trivially_copyable_v< T > &&sizeof(udata.cache) > = sizeof(T), bool >
std::enable_if_t<!std::is_trivially_copyable_v< T >||sizeof(udata.cache)< sizeof(T), bool >=true > constexpr T * data () noexcept
 
constexpr size_t heap_size () const noexcept
 
 if (nullptr !=t)
 
constexpr bool is_trivially_copyable () const noexcept
 Returns true if the underlying target function is TriviallyCopyable. More...
 
 new (target.template data< T >()) T(params...)
 
constexpr R operator() (A... args) const
 Delegated fast path target function invocation, see above. More...
 
delegate_toperator= (const delegate_t &o) noexcept
 
delegate_toperator= (delegate_t &&o) noexcept
 
constexpr bool operator== (const delegate_t< R, A... > &rhs) const noexcept
 Delegated fast path target function equality operator. More...
 
delegate_t target (type_, static_cast< size_type >(sizeof(T)), nt, cb_, eqop_)
 
constexpr size_t target_size () const noexcept
 Returns the size of underlying target function. More...
 
constexpr target_type type () const noexcept
 Return the func::target_type of this invocation function wrapper. More...
 

Static Public Member Functions

static delegate_t make (invocation_t cb_, equal_op_t eqop_) noexcept
 

Public Attributes

nt copy_ctor
 
nt move_ctor
 
return target
 

Protected Types

typedef bool(* equal_op_t) (const delegate_t &data_lhs, const delegate_t &data_rhs) noexcept
 
typedef R(* invocation_t) (delegate_t *__restrict_cxx__ const data, A... args)
 

Detailed Description

template<typename R, typename... A>
class jau::func::delegate_t< R, A >

Delegated target function object, providing a fast path target function invocation.

This static polymorphic target function delegate_t<R, A...> is contained by function<R(A...)> and completely holds up to 24 bytes sized TriviallyCopyable target function objects to avoiding cache misses.

Template Parameters
Rfunction return type
Afunction arguments
See also
Function Overview

Definition at line 377 of file functional.hpp.

Member Typedef Documentation

◆ size_type

template<typename R , typename... A>
typedef int32_t jau::func::delegate_t< R, A >::size_type

Utilize a reduced size type of int32_t.

Negative sign indicates limited 24 bytes cache usage, otherwise heap is being used.

Definition at line 383 of file functional.hpp.

◆ invocation_t

template<typename R , typename... A>
typedef R(* jau::func::delegate_t< R, A >::invocation_t) (delegate_t *__restrict_cxx__ const data, A... args)
protected

Definition at line 386 of file functional.hpp.

◆ equal_op_t

template<typename R , typename... A>
typedef bool(* jau::func::delegate_t< R, A >::equal_op_t) (const delegate_t &data_lhs, const delegate_t &data_rhs) noexcept
protectednoexcept

Definition at line 387 of file functional.hpp.

Constructor & Destructor Documentation

◆ ~delegate_t()

template<typename R , typename... A>
jau::func::delegate_t< R, A >::~delegate_t ( )
inlinenoexcept

Definition at line 520 of file functional.hpp.

◆ delegate_t() [1/2]

template<typename R , typename... A>
jau::func::delegate_t< R, A >::delegate_t ( const delegate_t< R, A > &  o)
inlinenoexcept

Definition at line 522 of file functional.hpp.

◆ delegate_t() [2/2]

template<typename R , typename... A>
jau::func::delegate_t< R, A >::delegate_t ( delegate_t< R, A > &&  o)
inlinenoexcept

Definition at line 549 of file functional.hpp.

Member Function Documentation

◆ make()

template<typename R , typename... A>
static delegate_t jau::func::delegate_t< R, A >::make ( invocation_t  cb_,
equal_op_t  eqop_ 
)
inlinestaticnoexcept

Definition at line 475 of file functional.hpp.

◆ data() [1/3]

template<typename R , typename... A>
template<typename T , typename... P>
template jau::func::delegate_t< R, A >::data ( )

◆ if()

template<typename R , typename... A>
jau::func::delegate_t< R, A >::if ( nullptr !  = t)
inline

Definition at line 505 of file functional.hpp.

◆ target()

template<typename R , typename... A>
delegate_t jau::func::delegate_t< R, A >::target ( type_  ,
static_cast< size_type sizeof(T),
nt  ,
cb_  ,
eqop_   
)

◆ new()

template<typename R , typename... A>
jau::func::delegate_t< R, A >::new ( target.template data< T >  ())

◆ operator=() [1/2]

template<typename R , typename... A>
delegate_t & jau::func::delegate_t< R, A >::operator= ( const delegate_t< R, A > &  o)
inlinenoexcept

Definition at line 575 of file functional.hpp.

◆ operator=() [2/2]

template<typename R , typename... A>
delegate_t & jau::func::delegate_t< R, A >::operator= ( delegate_t< R, A > &&  o)
inlinenoexcept

Definition at line 637 of file functional.hpp.

◆ data() [2/3]

template<typename R , typename... A>
template<typename T , std::enable_if_t< std::is_trivially_copyable_v< T > &&sizeof(udata.cache) > = sizeof(T), bool >
std::enable_if_t<!std::is_trivially_copyable_v< T >|| sizeof(udata.cache)< sizeof(T), bool >=true > constexpr const T * jau::func::delegate_t< R, A >::data ( ) const
inlineconstexprnoexcept

Definition at line 684 of file functional.hpp.

◆ data() [3/3]

template<typename R , typename... A>
template<typename T , std::enable_if_t< std::is_trivially_copyable_v< T > &&sizeof(udata.cache) > = sizeof(T), bool >
std::enable_if_t<!std::is_trivially_copyable_v< T >|| sizeof(udata.cache)< sizeof(T), bool >=true > constexpr T * jau::func::delegate_t< R, A >::data ( )
inlineconstexprnoexcept

Definition at line 700 of file functional.hpp.

◆ operator()()

template<typename R , typename... A>
constexpr R jau::func::delegate_t< R, A >::operator() ( A...  args) const
inlineconstexpr

Delegated fast path target function invocation, see above.

Parameters
argstarget function arguments
Returns
target function result

Definition at line 710 of file functional.hpp.

◆ operator==()

template<typename R , typename... A>
constexpr bool jau::func::delegate_t< R, A >::operator== ( const delegate_t< R, A... > &  rhs) const
inlineconstexprnoexcept

Delegated fast path target function equality operator.

Parameters
rhs
Returns

Definition at line 720 of file functional.hpp.

◆ is_trivially_copyable()

template<typename R , typename... A>
constexpr bool jau::func::delegate_t< R, A >::is_trivially_copyable ( ) const
inlineconstexprnoexcept

Returns true if the underlying target function is TriviallyCopyable.

Definition at line 725 of file functional.hpp.

Here is the caller graph for this function:

◆ heap_size()

template<typename R , typename... A>
constexpr size_t jau::func::delegate_t< R, A >::heap_size ( ) const
inlineconstexprnoexcept

Definition at line 727 of file functional.hpp.

Here is the caller graph for this function:

◆ cached_size()

template<typename R , typename... A>
constexpr size_t jau::func::delegate_t< R, A >::cached_size ( ) const
inlineconstexprnoexcept

Definition at line 728 of file functional.hpp.

◆ target_size()

template<typename R , typename... A>
constexpr size_t jau::func::delegate_t< R, A >::target_size ( ) const
inlineconstexprnoexcept

Returns the size of underlying target function.

Definition at line 731 of file functional.hpp.

Here is the caller graph for this function:

◆ type()

template<typename R , typename... A>
constexpr target_type jau::func::delegate_t< R, A >::type ( ) const
inlineconstexprnoexcept

Return the func::target_type of this invocation function wrapper.

Definition at line 734 of file functional.hpp.

Here is the caller graph for this function:

Member Data Documentation

◆ copy_ctor

template<typename R , typename... A>
nt jau::func::delegate_t< R, A >::copy_ctor
Initial value:
= [](delegate_t* i, const delegate_t* o) -> void {
new( i->template data<T>() ) T( *( o->template data<T>() ) );
}

Definition at line 509 of file functional.hpp.

◆ move_ctor

template<typename R , typename... A>
nt jau::func::delegate_t< R, A >::move_ctor
Initial value:
= [](delegate_t* i, delegate_t* o) -> void {
new( i->template data<T>() ) T( std::move( *( o->template data<T>() ) ) );
}

Definition at line 512 of file functional.hpp.

◆ target

template<typename R , typename... A>
return jau::func::delegate_t< R, A >::target

Definition at line 517 of file functional.hpp.


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