jaulib v1.3.6
Jau Support Library (C++, Java, ..)
Loading...
Searching...
No Matches
jau::final_opt< R, A > Class Template Reference

Class template jau::function is a general-purpose static-polymorphic function wrapper. More...

#include <functional.hpp>

Collaboration diagram for jau::final_opt< R, A >:

Public Types

typedef func::delegate_t< R, A... > delegate_type
 The delegated target function type, i.e.
 
typedef R result_type
 The target function return type R.
 

Public Member Functions

 function () noexcept
 Null function constructor.
 
template<typename C0, typename C1>
 function (C1 *base, R(C0::*mfunc)(A...)) noexcept
 Member function constructor.
 
 function (const function &o) noexcept=default
 
template<typename I>
 function (const I &data, R(*func)(I &, A...)) noexcept
 Capture by value (copy) function constructor.
 
 function (delegate_type _delegate, int dummy) noexcept
 Internally used delegate_t<R(A...)> constructor.
 
 function (function &&o) noexcept=default
 
template<typename I>
 function (I &&data, R(*func)(I &, A...)) noexcept
 Capture by value (move) function constructor.
 
template<typename I>
 function (I *data_ptr, R(*func)(I *, A...)) noexcept
 Capture by-reference function constructor.
 
template<typename L, std::enable_if_t<!std::is_same_v< L, std::shared_ptr< delegate_type > > &&!std::is_pointer_v< L > &&!std::is_same_v< L, R(A...)> &&!std::is_same_v< L, function< R(A...)> >, bool > = true>
 function (L func) noexcept
 Lambda function constructor.
 
 function (R(*func)(A...)) noexcept
 Free function constructor.
 
 function (std::nullptr_t) noexcept
 Null function constructor.
 
 function (uint64_t id, std::function< R(A...)> func) noexcept
 std::function constructor
 
constexpr bool is_null () const noexcept
 Returns true if this instance does not hold a callable target function, i.e.
 
constexpr bool is_target_trivially_copyable () const noexcept
 Returns true if the underlying target function is TriviallyCopyable.
 
constexpr operator bool () const noexcept
 Returns true if this instance holds a callable target function, i.e.
 
constexpr bool operator!= (const function< R(A...)> &rhs) const noexcept
 
constexpr R operator() (A... args)
 
constexpr R operator() (A... args) const
 
functionoperator= (const function &o) noexcept=default
 
functionoperator= (function &&o) noexcept=default
 
constexpr bool operator== (const function< R(A...)> &rhs) const noexcept
 
jau::type_info signature () const noexcept
 Returns signature of this function prototype R(A...) w/o underlying target function object.
 
constexpr size_t size () const noexcept
 Return the total size of this instance, may include heap allocated by delegate for bigger target functions.
 
constexpr size_t target_size () const noexcept
 Returns the size of underlying target function.
 
std::string toString () const
 Return a string representation of this instance.
 
constexpr func::target_type type () const noexcept
 Return the jau::func::type of this instance.
 

Static Public Member Functions

template<typename L>
static function< R(A...)> bind_lambda (L func) noexcept
 Lambda function bind factory.
 
template<typename L>
static function< R(A...)> bind_ylambda (L func) noexcept
 Y combinator Lambda function bind factory.
 

Detailed Description

template<typename R, typename... A>
class jau::final_opt< R, A >

Class template jau::function is a general-purpose static-polymorphic function wrapper.

See Function Overview.

Template Parameters
Rfunction return type
Afunction arguments
See also
Function Overview
Function Usage

Definition at line 1253 of file functional.hpp.

Member Typedef Documentation

◆ delegate_type

template<typename R, typename... A>
typedef func::delegate_t<R, A...> jau::final_opt< R, A >::delegate_type

The delegated target function type, i.e.

func::delegate_t<R, A...>

Definition at line 1256 of file functional.hpp.

◆ result_type

template<typename R, typename... A>
typedef R jau::final_opt< R, A >::result_type

The target function return type R.

Definition at line 1263 of file functional.hpp.

Member Function Documentation

◆ function() [1/12]

template<typename R, typename... A>
jau::final_opt< R, A >::function ( )
inlinenoexcept

Null function constructor.

Constructs an instance with a null target function.

See also
function Overview
function Usage

Definition at line 1273 of file functional.hpp.

Here is the caller graph for this function:

◆ function() [2/12]

template<typename R, typename... A>
jau::final_opt< R, A >::function ( std::nullptr_t )
inlinenoexcept

Null function constructor.

Constructs an instance with a null target function.

See also
function Overview
function Usage

Definition at line 1285 of file functional.hpp.

◆ function() [3/12]

template<typename R, typename... A>
jau::final_opt< R, A >::function ( delegate_type _delegate,
int dummy )
inlineexplicitnoexcept

Internally used delegate_t<R(A...)> constructor.

May utilize copy elision and/or named return value optimization (NRVO).

See also
function Overview
function Usage

Definition at line 1298 of file functional.hpp.

◆ function() [4/12]

template<typename R, typename... A>
jau::final_opt< R, A >::function ( R(* func )(A...))
inlinenoexcept

Free function constructor.

Constructs an instance by taking a free target function, which may also be a non-capturing lambda if explicitly bind_free().

See also
function Overview
function Usage

Definition at line 1310 of file functional.hpp.

◆ function() [5/12]

template<typename R, typename... A>
template<typename L, std::enable_if_t<!std::is_same_v< L, std::shared_ptr< delegate_type > > &&!std::is_pointer_v< L > &&!std::is_same_v< L, R(A...)> &&!std::is_same_v< L, function< R(A...)> >, bool > = true>
jau::final_opt< R, A >::function ( L func)
inlinenoexcept

Lambda function constructor.

Constructs an instance by taking a lambda function.

Template Parameters
Ltypename holding the lambda closure
Parameters
functhe lambda reference
See also
function Overview
function Usage

Definition at line 1331 of file functional.hpp.

◆ bind_lambda()

template<typename R, typename... A>
template<typename L>
static function< R(A...)> jau::final_opt< R, A >::bind_lambda ( L func)
inlinestaticnoexcept

Lambda function bind factory.

Constructs an instance by taking a lambda function.

Template Parameters
Ltypename holding the lambda closure
Parameters
functhe lambda reference
See also
function Overview
function Usage

Definition at line 1347 of file functional.hpp.

◆ bind_ylambda()

template<typename R, typename... A>
template<typename L>
static function< R(A...)> jau::final_opt< R, A >::bind_ylambda ( L func)
inlinestaticnoexcept

Y combinator Lambda function bind factory.

Constructs an instance by taking a lambda function, implementing a Y combinator and deducing this lambda closure, see ylambda_target_t.

Template Parameters
Ltypename holding the lambda closure
Parameters
functhe lambda reference
See also
ylambda_target_t
function Overview
function Usage

Definition at line 1368 of file functional.hpp.

◆ function() [6/12]

template<typename R, typename... A>
template<typename C0, typename C1>
jau::final_opt< R, A >::function ( C1 * base,
R(C0::* mfunc )(A...) )
inlinenoexcept

Member function constructor.

Constructs an instance by taking a member target function.

Template Parameters
C0class type holding the member-function
C1class derived from C0 or C0 of this base-pointer used to invoke the member-function
Parameters
basepointer to the class instance of the member function
mfuncmember function of class
See also
function Overview
function Usage

Definition at line 1386 of file functional.hpp.

◆ function() [7/12]

template<typename R, typename... A>
template<typename I>
jau::final_opt< R, A >::function ( const I & data,
R(* func )(I &, A...) )
inlinenoexcept

Capture by value (copy) function constructor.

Constructs an instance by copying the captured value and the given non-void function to an anonymous function using func::capval_target_t.

const I& data will be copied into func::capval_target_t and hence captured by-copy.

The function invocation will have the reference of the copied data being passed to the target function for efficiency.

Template Parameters
Itypename holding the captured data used by the function
Parameters
datadata type instance holding the captured data
funcfunction with R return value and A... arguments.
See also
function Overview
function Usage

Definition at line 1408 of file functional.hpp.

◆ function() [8/12]

template<typename R, typename... A>
template<typename I>
jau::final_opt< R, A >::function ( I && data,
R(* func )(I &, A...) )
inlinenoexcept

Capture by value (move) function constructor.

Constructs an instance by moving the captured value and copying the given non-void function to an anonymous function using func::capval_target_t.

I&& data will be moved into func::capval_target_t.

The function invocation will have the reference of the moved data being passed to the target function for efficiency.

Template Parameters
Itypename holding the captured data used by the function
Parameters
datadata type instance holding the captured data
funcfunction with R return value and A... arguments.
See also
function Overview
function Usage

Definition at line 1430 of file functional.hpp.

◆ function() [9/12]

template<typename R, typename... A>
template<typename I>
jau::final_opt< R, A >::function ( I * data_ptr,
R(* func )(I *, A...) )
inlinenoexcept

Capture by-reference function constructor.

Constructs an instance by passing the captured reference (pointer) to the value and non-void function to an anonymous function using func::capref_target_t.

The function invocation will have the reference of the data being passed to the target function.

Template Parameters
Itypename holding the captured data used by the function
Parameters
data_ptrdata type reference to instance holding the captured data
funcfunction with R return value and A... arguments.
See also
function Overview
function Usage

Definition at line 1450 of file functional.hpp.

◆ function() [10/12]

template<typename R, typename... A>
jau::final_opt< R, A >::function ( uint64_t id,
std::function< R(A...)> func )
inlinenoexcept

std::function constructor

Constructs an instance by copying the std::function to an anonymous function using func::std_target_t.

Notable, instance is holding the given unique uint64_t identifier to allow implementing the equality operator w/o RTTI, not supported by std::function.

Parameters
funcfree-function with R return value and A... arguments.
See also
function Overview
function Usage

Definition at line 1468 of file functional.hpp.

◆ function() [11/12]

template<typename R, typename... A>
jau::final_opt< R, A >::function ( const function & o)
defaultnoexcept

◆ function() [12/12]

template<typename R, typename... A>
jau::final_opt< R, A >::function ( function && o)
defaultnoexcept

◆ operator=() [1/2]

template<typename R, typename... A>
function & jau::final_opt< R, A >::operator= ( const function & o)
defaultnoexcept

◆ operator=() [2/2]

template<typename R, typename... A>
function & jau::final_opt< R, A >::operator= ( function && o)
defaultnoexcept

◆ type()

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

Return the jau::func::type of this instance.

Definition at line 1478 of file functional.hpp.

Here is the caller graph for this function:

◆ is_null()

template<typename R, typename... A>
bool jau::final_opt< R, A >::is_null ( ) const
inlineconstexprnoexcept

Returns true if this instance does not hold a callable target function, i.e.

is of func::target_type::null.

Definition at line 1481 of file functional.hpp.

Here is the caller graph for this function:

◆ operator bool()

template<typename R, typename... A>
jau::final_opt< R, A >::operator bool ( ) const
inlineexplicitconstexprnoexcept

Returns true if this instance holds a callable target function, i.e.

is not of func::target_type::null.

Definition at line 1484 of file functional.hpp.

◆ signature()

template<typename R, typename... A>
jau::type_info jau::final_opt< R, A >::signature ( ) const
inlinenoexcept

Returns signature of this function prototype R(A...) w/o underlying target function object.

Definition at line 1487 of file functional.hpp.

Here is the caller graph for this function:

◆ is_target_trivially_copyable()

template<typename R, typename... A>
bool jau::final_opt< R, A >::is_target_trivially_copyable ( ) const
inlineconstexprnoexcept

Returns true if the underlying target function is TriviallyCopyable.

Definition at line 1492 of file functional.hpp.

◆ size()

template<typename R, typename... A>
size_t jau::final_opt< R, A >::size ( ) const
inlineconstexprnoexcept

Return the total size of this instance, may include heap allocated by delegate for bigger target functions.

Definition at line 1495 of file functional.hpp.

Here is the caller graph for this function:

◆ target_size()

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

Returns the size of underlying target function.

Definition at line 1498 of file functional.hpp.

Here is the caller graph for this function:

◆ toString()

template<typename R, typename... A>
std::string jau::final_opt< R, A >::toString ( ) const
inline

Return a string representation of this instance.

The string representation contains the complete signature and detailed memory footprint.

Definition at line 1504 of file functional.hpp.

◆ operator()() [1/2]

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

Definition at line 1513 of file functional.hpp.

◆ operator()() [2/2]

template<typename R, typename... A>
R jau::final_opt< R, A >::operator() ( A... args)
inlineconstexpr

Definition at line 1516 of file functional.hpp.

◆ operator==()

template<typename R, typename... A>
bool jau::final_opt< R, A >::operator== ( const function< R(A...)> & rhs) const
inlineconstexprnoexcept

Definition at line 1520 of file functional.hpp.

◆ operator!=()

template<typename R, typename... A>
bool jau::final_opt< R, A >::operator!= ( const function< R(A...)> & rhs) const
inlineconstexprnoexcept

Definition at line 1523 of file functional.hpp.


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