26#ifndef JAU_FUNCTIONAL_HPP_
27#define JAU_FUNCTIONAL_HPP_
379 template<
typename R,
typename... A>
387 return std::is_trivially_copyable_v<T> &&
388 sizeof(udata.cache) >=
sizeof(T);
392 return std::is_trivially_copyable_v<T> &&
393 sizeof(udata.cache) <
sizeof(T);
397 return !std::is_trivially_copyable_v<T> ||
398 sizeof(udata.cache) <
sizeof(T);
402 return !std::is_trivially_copyable_v<T> &&
403 std::is_destructible_v<T> &&
404 std::is_copy_constructible_v<T> &&
405 std::is_move_constructible_v<T>;
419 typedef bool(*
equal_op_t)(
const delegate_t& data_lhs,
const delegate_t& data_rhs)
noexcept;
438 union target_data_t {
443 const target_func_t* m_tfunc;
447 constexpr delegate_t(
const target_func_t& tfunc) noexcept
452 constexpr delegate_t(
const target_func_t& tfunc,
bool) noexcept
455 udata.heap = ::malloc(m_tfunc->size);
458 constexpr bool useHeap() const noexcept {
459 return m_tfunc->non_trivial ||
static_cast<size_type
>(
sizeof(udata.cache) ) < m_tfunc->size;
462 void clear() noexcept {
463 if( useHeap() && udata.heap ) {
464 if( m_tfunc->non_trivial ) {
465 m_tfunc->non_trivial->dtor(
this);
468 udata.heap =
nullptr;
474 static delegate_t
make(
const target_func_t& tfunc)
noexcept
476 delegate_t target(tfunc);
477 std::memset(target.udata.cache, 0,
sizeof(target.udata.cache));
482 template<
typename T,
typename... P,
483 std::enable_if_t<use_trivial_cache<T>(),
bool> =
true>
484 static delegate_t
make(
const target_func_t& tfunc, P... params)
noexcept
486 delegate_t target(tfunc);
487 new( target.template
data<T>() ) T(params...);
492 template<
typename T,
typename... P,
493 std::enable_if_t<use_trivial_heap<T>(),
bool> =
true>
494 static delegate_t
make(
const target_func_t& tfunc, P... params)
noexcept
496 delegate_t target(tfunc,
true);
497 new( target.template
data<T>() ) T(params...);
502 template<
typename T,
typename... P,
503 std::enable_if_t<use_nontrivial_heap<T>(),
bool> =
true>
504 static delegate_t
make(
const target_func_t& tfunc, P... params)
noexcept
506 delegate_t target(tfunc,
true);
507 new( target.template
data<T>() ) T(params...);
513 std::enable_if_t<!use_nontrivial_heap<T>(),
bool> =
true>
518 std::enable_if_t<use_nontrivial_heap<T>(),
bool> =
true>
521 static non_trivial_t nt {
523 [](delegate_t* i) ->
void {
530 [](delegate_t* i,
const delegate_t* o) ->
void {
534 [](delegate_t* i, delegate_t* o) ->
void {
535 new( i->template
data<T>() ) T( std::move( *( o->template
data<T>() ) ) );
544 : m_tfunc( o.m_tfunc )
547 udata.heap = ::malloc(m_tfunc->size);
549 ABORT(
"Error: bad_alloc: heap allocation failed");
552 if( m_tfunc->non_trivial ) {
553 m_tfunc->non_trivial->copy_ctor(
this, &o);
555 ::memcpy(udata.heap, o.udata.heap, m_tfunc->size);
558 ::memcpy(udata.cache, o.udata.cache, m_tfunc->size);
563 : m_tfunc( std::move(o.m_tfunc) )
566 if( m_tfunc->non_trivial ) {
567 udata.heap = ::malloc(m_tfunc->size);
569 ABORT(
"Error: bad_alloc: heap allocation failed");
572 m_tfunc->non_trivial->move_ctor(
this, &o);
573 m_tfunc->non_trivial->dtor(&o);
576 udata.heap = std::move( o.udata.heap );
578 o.udata.heap =
nullptr;
580 ::memcpy(udata.cache, o.udata.cache, m_tfunc->size);
590 if( !useHeap() && !o.useHeap() ) {
594 ::memcpy(udata.cache, o.udata.cache, m_tfunc->size);
595 }
else if( useHeap() && o.useHeap() && m_tfunc->size >= o.m_tfunc->size ) {
597 if( m_tfunc->non_trivial ) {
598 m_tfunc->non_trivial->dtor(
this);
601 if( m_tfunc->non_trivial ) {
602 m_tfunc->non_trivial->copy_ctor(
this, &o);
604 ::memcpy(udata.heap, o.udata.heap, m_tfunc->size);
612 udata.heap = ::malloc(m_tfunc->size);
614 ABORT(
"Error: bad_alloc: heap allocation failed");
617 if( m_tfunc->non_trivial ) {
618 m_tfunc->non_trivial->copy_ctor(
this, &o);
620 ::memcpy(udata.heap, o.udata.heap, m_tfunc->size);
623 ::memcpy(udata.cache, o.udata.cache, m_tfunc->size);
638 if( m_tfunc->non_trivial ) {
639 udata.heap = ::malloc(m_tfunc->size);
641 ABORT(
"Error: bad_alloc: heap allocation failed");
644 m_tfunc->non_trivial->move_ctor(
this, &o);
645 m_tfunc->non_trivial->dtor(&o);
648 udata.heap = std::move( o.udata.heap );
650 o.udata.heap =
nullptr;
652 ::memcpy(udata.cache, o.udata.cache, m_tfunc->size);
658 std::enable_if_t<use_trivial_cache<T>(),
bool> =
true>
659 constexpr const T*
data() const noexcept {
663 std::enable_if_t<use_trivial_cache<T>(),
bool> =
true>
669 std::enable_if_t<use_any_heap<T>(),
bool> =
true>
670 constexpr const T*
data() const noexcept {
674 std::enable_if_t<use_any_heap<T>(),
bool> =
true>
686 return m_tfunc->cb(
const_cast<delegate_t*
>(
this), args...);
695 constexpr bool operator==(
const delegate_t<R, A...>& rhs)
const noexcept {
696 return m_tfunc->eqop(*
this, rhs);
702 constexpr size_t heap_size() const noexcept {
return useHeap() ? m_tfunc->size : 0; }
703 constexpr size_t cached_size() const noexcept {
return !useHeap() ? m_tfunc->size : 0; }
706 constexpr size_t target_size() const noexcept {
return m_tfunc->size; }
723 template<
typename R,
typename... A>
733 constexpr static bool equal_op_impl(
const delegate_type& lhs,
const delegate_type& rhs)
noexcept {
734 return lhs.type() == rhs.type();
737 constexpr static void dtor(delegate_type* target)
noexcept {
740 static const delegate_type::target_func_t& get() {
741 static typename delegate_type::target_func_t tf { invoke_impl, equal_op_impl,
nullptr, 0, target_type::null };
747 return delegate_type::make(get());
761 template<
typename R,
typename C0,
typename C1,
typename... A>
768#if defined(__GNUC__) && !defined(__clang__)
776 typedef R(*function_t)(C0*, A...);
782 constexpr data_type(
C1 *_base, R(C0::*_method)(A...)) noexcept
788 function = (function_t)(_base->*_method);
793 constexpr static R invoke_impl(delegate_type*
__restrict_cxx__ const data, A... args) {
795 return ( *(d->function) )(d->base, args...);
798 constexpr static bool equal_op_impl(
const delegate_type& lhs_,
const delegate_type& rhs_)
noexcept {
799 const data_type* lhs = lhs_.template data<const data_type>();
800 const data_type* rhs = rhs_.template data<const data_type>();
802 ( lhs_.type() == rhs_.type() &&
803 lhs->base == rhs->base &&
804 lhs->function== rhs->function
820 constexpr static R invoke_impl(delegate_type*
__restrict_cxx__ const data, A... args) {
822 return (d->base->*d->method)(args...);
825 constexpr static bool equal_op_impl(
const delegate_type& lhs_,
const delegate_type& rhs_)
noexcept {
826 const data_type* lhs = lhs_.template data<const data_type>();
827 const data_type* rhs = rhs_.template data<const data_type>();
829 ( lhs_.type() == rhs_.type() &&
830 lhs->base == rhs->base &&
831 lhs->method == rhs->method
835 static const delegate_type::target_func_t& get() {
836 static typename delegate_type::target_func_t tf {
837 invoke_impl, equal_op_impl,
838 delegate_type::template getNonTrivialCtor<data_type>(),
839 sizeof(data_type), target_type::member };
854 std::enable_if_t<std::is_base_of_v<C0, C1>,
bool> =
true) noexcept
856 return base && method ? delegate_type::template
make<data_type>( get(), base, method ) : func::null_target_t<R, A...>::delegate();
868 template<
typename R,
typename... A>
881 constexpr static R invoke_impl(delegate_type*
__restrict_cxx__ const data, A... args) {
882 return ( *(data->template data<data_type>()->function) )(args...);
885 constexpr static bool equal_op_impl(
const delegate_type& lhs_,
const delegate_type& rhs_)
noexcept {
886 const data_type* lhs = lhs_.template data<const data_type>();
887 const data_type* rhs = rhs_.template data<const data_type>();
889 ( lhs_.type() == rhs_.type() &&
890 lhs->function== rhs->function
893 static const delegate_type::target_func_t& get() {
894 static typename delegate_type::target_func_t tf {
895 invoke_impl, equal_op_impl,
896 delegate_type::template getNonTrivialCtor<data_type>(),
897 sizeof(data_type), target_type::free };
916 template<
typename R,
typename L,
typename...A>
932 constexpr static R invoke_impl(delegate_type*
__restrict_cxx__ const data, A... args) {
933 return ( data->template data<data_type>()->function )(args...);
936 constexpr static bool equal_op_impl(
const delegate_type& lhs_,
const delegate_type& rhs_)
noexcept {
937 const data_type* lhs = lhs_.template data<const data_type>();
938 const data_type* rhs = rhs_.template data<const data_type>();
940 ( lhs_.type() == rhs_.type() &&
941 lhs->detail_size() == rhs->detail_size() &&
942 lhs->sig == rhs->sig &&
943 0 == ::memcmp((
void*)&lhs->function, (
void*)&rhs->function,
sizeof(lhs->function))
946 static const delegate_type::target_func_t& get() {
947 static typename delegate_type::target_func_t tf {
948 invoke_impl, equal_op_impl,
949 delegate_type::template getNonTrivialCtor<data_type>(),
950 sizeof(data_type), target_type::lambda };
1006 template<
typename R,
typename L,
typename...A>
1027 constexpr static R invoke_impl(delegate_type*
__restrict_cxx__ const data, A... args) {
1028 return ( data->template data<data_type>()->function )(*data, args...);
1031 constexpr static bool equal_op_impl(
const delegate_type& lhs_,
const delegate_type& rhs_)
noexcept {
1032 const data_type* lhs = lhs_.template data<const data_type>();
1033 const data_type* rhs = rhs_.template data<const data_type>();
1034 return lhs == rhs ||
1035 ( lhs_.type() == rhs_.type() &&
1036 lhs->detail_size() == rhs->detail_size() &&
1037 lhs->sig == rhs->sig &&
1038 0 == ::memcmp((
void*)&lhs->function, (
void*)&rhs->function,
sizeof(lhs->function))
1041 static const delegate_type::target_func_t& get() {
1042 static typename delegate_type::target_func_t tf {
1043 invoke_impl, equal_op_impl,
1044 delegate_type::template getNonTrivialCtor<data_type>(),
1045 sizeof(data_type), target_type::ylambda };
1064 template<
typename R,
typename I,
typename... A>
1081 constexpr static R invoke_impl(delegate_type*
__restrict_cxx__ const data, A... args) {
1083 return (*d->function)(d->data, args...);
1086 constexpr static bool equal_op_impl(
const delegate_type& lhs_,
const delegate_type& rhs_)
noexcept {
1087 const data_type* lhs = lhs_.template data<const data_type>();
1088 const data_type* rhs = rhs_.template data<const data_type>();
1089 return lhs == rhs ||
1090 ( lhs_.type() == rhs_.type() &&
1091 lhs->function == rhs->function &&
1092 lhs->data == rhs->data
1095 static const delegate_type::target_func_t& get() {
1096 static typename delegate_type::target_func_t tf {
1097 invoke_impl, equal_op_impl,
1098 delegate_type::template getNonTrivialCtor<data_type>(),
1099 sizeof(data_type), target_type::capval };
1122 template<
typename R,
typename I,
typename... A>
1137 constexpr static R invoke_impl(delegate_type*
__restrict_cxx__ const data, A... args) {
1139 return (*d->function)(d->data_ptr, args...);
1142 constexpr static bool equal_op_impl(
const delegate_type& lhs_,
const delegate_type& rhs_)
noexcept {
1143 const data_type* lhs = lhs_.template data<const data_type>();
1144 const data_type* rhs = rhs_.template data<const data_type>();
1145 return lhs == rhs ||
1146 ( lhs_.type() == rhs_.type() &&
1147 lhs->function == rhs->function &&
1148 lhs->data_ptr == rhs->data_ptr
1151 static const delegate_type::target_func_t& get() {
1152 static typename delegate_type::target_func_t tf {
1153 invoke_impl, equal_op_impl,
1154 delegate_type::template getNonTrivialCtor<data_type>(),
1155 sizeof(data_type), target_type::capref };
1176 template<
typename R,
typename... A>
1186 data_type(uint64_t id_, std::function<R(A...)> function_) noexcept
1192 constexpr static R invoke_impl(delegate_type*
__restrict_cxx__ const data, A... args) {
1195 return d->function(args...);
1201 constexpr static bool equal_op_impl(
const delegate_type& lhs_,
const delegate_type& rhs_)
noexcept {
1202 const data_type* lhs = lhs_.template data<const data_type>();
1203 const data_type* rhs = rhs_.template data<const data_type>();
1204 return lhs == rhs ||
1205 ( lhs_.type() == rhs_.type() &&
1206 lhs->id == rhs->id &&
1207 lhs->detail_size() && rhs->detail_size()
1210 static const delegate_type::target_func_t& get() {
1211 static typename delegate_type::target_func_t tf {
1212 invoke_impl, equal_op_impl,
1213 delegate_type::template getNonTrivialCtor<data_type>(),
1214 sizeof(data_type), target_type::std };
1228 return static_cast<uint32_t
>(rhs);
1241 template<
typename Signature>
1254 template<
typename R,
typename... A>
1276 : target(
func::null_target_t<R, A...>::delegate() )
1288 : target( func::null_target_t<R, A...>::delegate() )
1301 : target( std::move(_delegate) )
1313 : target(
func::free_target_t<R, A...>::delegate(
func) )
1327 template<
typename L,
1328 std::enable_if_t<!std::is_same_v<L, std::shared_ptr<delegate_type>> &&
1329 !std::is_pointer_v<L> &&
1330 !std::is_same_v<L, R(A...)> &&
1331 !std::is_same_v<L,
function<R(A...)>>
1334 : target( func::lambda_target_t<R, L, A...>::delegate(
func) )
1348 template<
typename L>
1351 return function<R(A...)>( jau::func::lambda_target_t<R, L, A...>::delegate(
func), 0 );
1369 template<
typename L>
1372 return function<R(A...)>( jau::func::ylambda_target_t<R, L, A...>::delegate(
func), 0 );
1387 template<
typename C0,
typename C1>
1389 : target(
func::member_target_t<R, C0,
C1, A...>::delegate(base, mfunc) )
1409 template<
typename I>
1411 : target(
func::capval_target_t<R, I, A...>::delegate(data,
func) )
1431 template<
typename I>
1433 : target(
func::capval_target_t<R, I, A...>::delegate(
std::forward<I>(data),
func) )
1451 template<
typename I>
1453 : target(
func::capref_target_t<R, I, A...>::delegate(data_ptr,
func) )
1471 : target( func::std_target_t<R, A...>::delegate(
id,
func) )
1486 explicit constexpr operator bool() const noexcept {
return !
is_null(); }
1497 constexpr size_t size() const noexcept {
return target.heap_size() +
sizeof(*this); }
1500 constexpr size_t target_size() const noexcept {
return target.target_size(); }
1508 std::to_string(
target_size() ) +
" / ( delegate_t " +
1509 std::to_string(
sizeof( target ) ) +
" + target_vdata " +
1510 std::to_string( target.heap_size() ) +
" -> "+
1511 std::to_string(
size() ) +
" ), trivial_cpy "+
1512 std::to_string( target.is_trivially_copyable() ) +
" ) ";
1516 return target(args...);
1519 return target(args...);
1523 return target.operator==(rhs.target);
1545 template<
typename Rl,
typename... Al,
template <
typename...>
class Fl = function,
1546 typename Rr,
typename... Ar,
template <
typename...>
class Fr = function,
1547 std::enable_if_t< !std::is_same_v< Fl<Rl(Al...)>, Fr<Rr(Ar...)> >
1571 template<
typename Rl,
typename... Al,
template <
typename...>
class Fl = function,
1572 typename Rr,
typename... Ar,
template <
typename...>
class Fr = function,
1573 std::enable_if_t< std::is_same_v< Fl<Rl(Al...)>, Fr<Rr(Ar...)> >
1575 bool operator==(
const function<Rl(Al...)>& lhs,
const function<Rr(Ar...)>& rhs)
noexcept
1576 {
return lhs.operator==( rhs ); }
1592 template<
typename Rl,
typename... Al,
template <
typename...>
typename Fl =
function,
1593 typename Rr,
typename... Ar,
template <
typename...>
typename Fr =
function>
1595 {
return !( lhs == rhs ); }
1604 template<
class R,
class... A>
1615 template<
class R,
class... A>
1617 {
return !( lhs == nullptr ); }
1626 template<
class R,
class... A>
1637 template<
class R,
class... A>
1639 {
return !(
nullptr == rhs ); }
1656 template<
typename R,
typename C0,
typename C1,
typename... A>
1659 return function<R(A...)>( func::member_target_t<R, C0, C1, A...>::delegate(base, mfunc), 0 );
1676 template<
typename R,
typename C,
typename... A>
1679 return function<R(A...)>( func::member_target_t<R, C, C, A...>::delegate(base, mfunc), 0 );
1696 template<
typename C0,
typename C1,
typename... A>
1699 return function<void(A...)>( func::member_target_t<void, C0, C1, A...>::delegate(base, mfunc), 0 );
1715 template<
typename C,
typename... A>
1718 return function<void(A...)>( func::member_target_t<void, C, C, A...>::delegate(base, mfunc), 0 );
1733 template<
typename R,
typename... A>
1736 return function<R(A...)>( func::free_target_t<R, A...>::delegate(
func), 0 );
1750 template<
typename... A>
1753 return function<void(A...)>( func::free_target_t<void, A...>::delegate(
func), 0 );
1774 template<
typename R,
typename I,
typename... A>
1777 return function<R(A...)>( func::capval_target_t<R, I, A...>::delegate(data,
func), 0 );
1797 template<
typename I,
typename... A>
1800 return function<void(A...)>( func::capval_target_t<void, I, A...>::delegate(data,
func), 0 );
1821 template<
typename R,
typename I,
typename... A>
1824 return function<R(A...)>( func::capval_target_t<R, I, A...>::delegate(std::forward<I>(data),
func), 0 );
1844 template<
typename I,
typename... A>
1847 return function<void(A...)>( func::capval_target_t<void, I, A...>::delegate(std::forward<I>(data),
func), 0 );
1866 template<
typename R,
typename I,
typename... A>
1869 return function<R(A...)>( func::capref_target_t<R, I, A...>::delegate(data_ptr,
func), 0 );
1887 template<
typename I,
typename... A>
1890 return function<void(A...)>( func::capref_target_t<void, I, A...>::delegate(data_ptr,
func), 0 );
1908 template<
typename R,
typename... A>
1911 return function<R(A...)>( func::std_target_t<R, A...>::delegate(
id,
func), 0 );
1928 template<
typename... A>
1931 return function<void(A...)>( func::std_target_t<void, A...>::delegate(
id,
func), 0 );
Class template jau::function is a general-purpose static-polymorphic function wrapper.
function(delegate_type _delegate, int dummy) noexcept
Internally used delegate_t<R(A...)> constructor.
constexpr R operator()(A... args) const
function(function &&o) noexcept=default
constexpr bool operator!=(const function< R(A...)> &rhs) const noexcept
function(I &&data, R(*func)(I &, A...)) noexcept
Capture by value (move) function constructor.
function(C1 *base, R(C0::*mfunc)(A...)) noexcept
Member function constructor.
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.
function(R(*func)(A...)) noexcept
Free function constructor.
constexpr R operator()(A... args)
function(const function &o) noexcept=default
function() noexcept
Null function constructor.
function(I *data_ptr, R(*func)(I *, A...)) noexcept
Capture by-reference function constructor.
constexpr bool is_null() const noexcept
Returns true if this instance does not hold a callable target function, i.e.
function(const I &data, R(*func)(I &, A...)) noexcept
Capture by value (copy) function constructor.
function(std::nullptr_t) noexcept
Null function constructor.
static function< R(A...)> bind_ylambda(L func) noexcept
Y combinator Lambda function bind factory.
func::delegate_t< R, A... > delegate_type
The delegated target function type, i.e.
constexpr bool operator==(const function< R(A...)> &rhs) const noexcept
constexpr size_t target_size() const noexcept
Returns the size of underlying target function.
R result_type
The target function return type R.
constexpr bool is_target_trivially_copyable() const noexcept
Returns true if the underlying target function is TriviallyCopyable.
function & operator=(function &&o) noexcept=default
function(L func) noexcept
Lambda function constructor.
jau::type_info signature() const noexcept
Returns signature of this function prototype R(A...) w/o underlying target function object.
function & operator=(const function &o) noexcept=default
constexpr size_t size() const noexcept
Return the total size of this instance, may include heap allocated by delegate for bigger target func...
function(uint64_t id, std::function< R(A...)> func) noexcept
std::function constructor
static function< R(A...)> bind_lambda(L func) noexcept
Lambda function bind factory.
constexpr size_t cached_size() const noexcept
constexpr bool operator==(const delegate_t< R, A... > &rhs) const noexcept
Delegated fast path target function equality operator.
static delegate_t make(const target_func_t &tfunc) noexcept
constexpr T * data() noexcept
static non_trivial_t * getNonTrivialCtor() noexcept
constexpr size_t heap_size() const noexcept
constexpr bool is_trivially_copyable() const noexcept
Returns true if the underlying target function is TriviallyCopyable.
static delegate_type delegate(const I &data, R(*function)(I &, A...)) noexcept
static delegate_type delegate() noexcept
static delegate_type delegate(L function) noexcept
delegate_t & operator=(delegate_t &&o) noexcept
static delegate_t make(const target_func_t &tfunc, P... params) noexcept
constexpr size_t target_size() const noexcept
Returns the size of underlying target function.
jau::nsize_t size_type
Utilize a natural size type jau::nsize_t.
static delegate_type delegate(R(*function)(A...)) noexcept
static delegate_type delegate(I *data_ptr, R(*function)(I *, A...)) noexcept
delegate_t(delegate_t &&o) noexcept
static constexpr bool use_nontrivial_heap()
static delegate_type delegate(C1 *base, R(C0::*method)(A...), std::enable_if_t< std::is_base_of_v< C0, C1 >, bool >=true) noexcept
Construct a delegate_t<R, A...> instance from given this base-pointer and member-function.
delegate_t & operator=(const delegate_t &o) noexcept
static delegate_type delegate(uint64_t id, std::function< R(A...)> function) noexcept
constexpr const T * data() const noexcept
static constexpr bool use_trivial_heap()
static constexpr bool use_trivial_cache()
delegate_t< R, A... > delegate_type
static delegate_type delegate(I &&data, R(*function)(I &, A...)) noexcept
static constexpr bool use_any_heap()
delegate_t(const delegate_t &o) noexcept
constexpr target_type type() const noexcept
Return the func::target_type of this invocation function wrapper.
constexpr R operator()(A... args) const
Delegated fast path target function invocation, see above.
Class template jau::function is a general-purpose static-polymorphic function wrapper.
Generic type information using either Runtime type information (RTTI) or Compile time type informatio...
#define ABORT(...)
Use for unconditional ::abort() call with given messages, prefix '[elapsed_time] ABORT @ file:line fu...
std::string to_string(const endian_t v) noexcept
Return std::string representation of the given endian.
#define PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS
#define PRAGMA_DISABLE_WARNING_PEDANTIC
#define PRAGMA_DISABLE_WARNING_PUSH
#define final_opt
Optional generic usage of final keyword w/o negative performance impact.
constexpr std::enable_if_t< sizeof(Dest)==sizeof(Source) &&std::is_pointer_v< Source > &&std::is_pointer_v< Dest >, Dest > pointer_cast(const Source &src) noexcept
A constexpr pointer cast implementation for C++17, inspired by C++20 bit_cast<>(arg).
#define __restrict_cxx__
Wrap C++ extension __restrict__ covering C99's restrict feature keyword.
#define PRAGMA_DISABLE_WARNING_POP
jau::type_info make_ctti(bool identity_instance=false) noexcept
Constructs a jau::type_info instance based on given type T using template Compile Time Type Informati...
jau::function< R(A...)> bind_member(C1 *base, R(C0::*mfunc)(A...)) noexcept
Bind given class instance and non-void member function to an anonymous function using func_member_tar...
jau::function< R(A...)> bind_free(R(*func)(A...)) noexcept
Bind given non-void free-function to an anonymous function using func::free_target_t.
jau::function< R(A...)> bind_std(uint64_t id, std::function< R(A...)> func) noexcept
Bind given non-void std::function to an anonymous function using func::std_target_t.
target_type
func::target_type identifier for the target function delegate_t<R, A...> object, exposed by jau::func...
jau::function< R(A...)> bind_capval(const I &data, R(*func)(I &, A...)) noexcept
Bind given data by copying the captured value and the given non-void function to an anonymous functio...
jau::function< R(A...)> bind_capref(I *data_ptr, R(*func)(I *, A...)) noexcept
Bind given data by passing the captured reference (pointer) to the value and non-void function to an ...
constexpr uint32_t number(const func::target_type rhs) noexcept
@ null
Denotes a func::null_target_t.
@ lambda
Denotes a func::lambda_target_t.
@ capval
Denotes a func::capval_target_t.
@ capref
Denotes a func::capref_target_t.
@ member
Denotes a func::member_target_t.
@ free
Denotes a func::free_target_t.
@ ylambda
Denotes a func::ylambda_target_t.
uint_fast32_t nsize_t
Natural 'size_t' alternative using uint_fast32_t as its natural sized type.
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
bool operator==(const callocator< T1 > &lhs, const callocator< T2 > &rhs) noexcept
bool operator!=(const callocator< T1 > &lhs, const callocator< T2 > &rhs) noexcept
C++ conform Pointer to Member Function (PMF)
data_type(R(*_function)(A...)) noexcept
bool(* equal_op_t)(const delegate_t &data_lhs, const delegate_t &data_rhs) noexcept
invocation_t cb
Delegated specialization callback.
void(* move_ctor_t)(delegate_t *, delegate_t *)
data_type(I &&_data, R(*_function)(I &, A...)) noexcept
data_type(uint64_t id_, std::function< R(A...)> function_) noexcept
data_type(I *_data_ptr, R(*_function)(I *, A...)) noexcept
R(* invocation_t)(delegate_t *__restrict_cxx__ const data, A... args)
data_type(const I &_data, R(*_function)(I &, A...)) noexcept
constexpr size_t detail_size() const noexcept
data_type(L _function) noexcept
constexpr data_type(C1 *_base, R(C0::*_method)(A...)) noexcept
equal_op_t eqop
Delegated specialization equality operator.
void(* dtor_t)(delegate_t *)
non_trivial_t * non_trivial
void(* copy_ctor_t)(delegate_t *, const delegate_t *)