19template<
class R,
class ...A>
23 using InvokerPtr = R(*)(
void*, A && ...);
34 template <R(*TFunction)(A...)>
38 return{ functionInvoker<TFunction> };
42 template <
class C, R(C::*TMethod)(A...)>
46 return{ pObject, methodInvoker<C, TMethod> };
50 template <
class C, R(C::*TMethod)(A...)>
54 return{ &obj, methodInvoker<C, TMethod> };
58 template <
class C, R(C::*TMethod)(A...)
const>
62 return{
const_cast<C*
>(pObject), constMethodInvoker<C, TMethod> };
66 template <
class C, R(C::*TMethod)(A...)
const>
70 return{
const_cast<C*
>(&obj), constMethodInvoker<C, TMethod> };
76 if (this->is_static())
78 return this->pInvoker == rhs.pInvoker;
81 return (this->pInstance == rhs.pInstance) && (this->pInvoker == rhs.pInvoker);
84 bool operator!=(
const slim_delegate& rhs)
const noexcept
90 slim_delegate(std::nullptr_t) noexcept : slim_delegate(
nullptr,
nullptr) { }
94 if (this->is_static())
96 return this->pInvoker ==
nullptr;
99 return this->pInstance ==
nullptr || this->pInvoker ==
nullptr;
104 return !(*
this ==
nullptr);
107 explicit operator bool()const noexcept
109 return *
this !=
nullptr;
113 R operator()(A... args)
const
115 return pInvoker(this->pInstance, std::forward<A>(args)...);
119 slim_delegate(InvokerPtr invokerPtr) noexcept
120 : pInstance(
this), pInvoker(invokerPtr)
124 slim_delegate(
void* pObject, InvokerPtr invokerPtr) noexcept
125 : pInstance(pObject), pInvoker(invokerPtr)
129 bool is_static(
void)
const
131 return this->pInstance ==
this;
135 template <R(*TFunction)(A...)>
136 static R functionInvoker(
void*
const, A&& ... args)
138 return TFunction(std::move(args)...);
141 template <
class C, R(C::*TMethod)(A...)>
142 static R methodInvoker(
void* pObject, A&& ... args)
144 return (
static_cast<C*
>(pObject)->*TMethod)(std::move(args)...);
147 template <
class C, R(C::*TMethod)(A...)
const>
148 static R constMethodInvoker(
void* pObject, A&& ... args)
150 return (
static_cast<const C*
>(pObject)->*TMethod)(std::move(args)...);
Definition: slim_delegate.hxx:12
bool operator!=(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string on inequality.
Definition: BasicString.hxx:1944
bool operator==(const BasicString< CharType, Alloc > &left, const BasicString< CharType, Alloc > &right)
Compares the left string to the right string on equality.
Definition: BasicString.hxx:1908
Root namespace for the PLCnext API
class ARP_DEPRECATED("Use Arp::Enum<T> instead.") EnumStrings
Deprecated! The class implements an adapter for enums to define the string literals of the enum entri...
Definition: EnumStrings.hxx:38