/* Zeta API - Z/classes/ObjectMemberFunction.hpp ______ ______________ ___ |__ / | ___|___ ___|/ \ / /__| __| | | / - \ /______|_____| |__| /__/ \__\ Copyright (C) 2006-2024 Manuel Sainz de Baranda y Goñi. Released under the terms of the GNU Lesser General Public License v3. */ #ifndef Z_classes_ObjectMemberFunction_HPP #define Z_classes_ObjectMemberFunction_HPP #include #include #if Z_HAS(MemberFunction) # define Z_HAS_ObjectMemberFunction 1 namespace Zeta { template struct ObjectMemberFunction; template struct ObjectMemberFunction : MemberFunction { NaT *object; Z_INLINE ObjectMemberFunction() Z_NOTHROW Z_DEFAULTED({}) # if Z_DIALECT_HAS(CPP11, INHERITING_CONSTRUCTORS) using MemberFunction::MemberFunction; # else template ::is_member_function_pointer && TypeIsSame::flow::to_function::end::to_unqualified, r(p...)>::value >::type> Z_INLINE ObjectMemberFunction(m function) Z_NOTHROW : MemberFunction(function) {} # endif # ifdef Z_NULLPTR Z_CT(CPP11) ObjectMemberFunction(NullPtr) Z_NOTHROW : MemberFunction(nullptr), object(nullptr) {}; # endif template ::is_void_pointer || (Type::is_pointer && Type::flow::pointee_type::is_class)) && Type::is_member_function_pointer && TypeIsSame::flow::to_function::end::to_unqualified, r(p...)>::value >::type> Z_INLINE ObjectMemberFunction(o object, m function) Z_NOTHROW : MemberFunction(function), object(reinterpret_cast(object)) {} template ::is_class && Type::is_member_function_pointer && TypeIsSame::flow::to_function::end::to_unqualified, r(p...)>::value >::type> Z_INLINE ObjectMemberFunction(const o &object, m function) Z_NOTHROW : MemberFunction(function), object(reinterpret_cast(&object)) {} template ::is_class>::type> Z_INLINE operator o *() const Z_NOTHROW {return reinterpret_cast(object);} template Z_INLINE typename TypeIf::is_class, ObjectMemberFunction &>::type operator =(o *rhs) Z_NOTHROW { object = reinterpret_cast(rhs); return *this; } template Z_INLINE typename TypeIf::is_class, ObjectMemberFunction &>::type operator =(const o &rhs) Z_NOTHROW { object = reinterpret_cast(&rhs); return *this; } template Z_INLINE typename TypeIf< Type::is_member_function_pointer && TypeIsSame::flow::to_function::end::to_unqualified, r(p...)>::value, ObjectMemberFunction &>::type operator =(m rhs) Z_NOTHROW { this->function = reinterpret_cast(rhs); return *this; } Z_INLINE r operator ()(typename Type

::to_forwardable... arguments) const {return (object->*this->function)(arguments...);} template Z_INLINE r operator ()(o *object, typename Type

::to_forwardable... arguments) const {return (reinterpret_cast(object)->*this->function)(arguments...);} template Z_INLINE r operator ()(const o &object, typename Type

::to_forwardable... arguments) const {return (reinterpret_cast(&object)->*this->function)(arguments...);} template Z_INLINE typename TypeIf< (Type::is_void || Type::is_class) && Type::is_member_function_pointer && TypeIsSame::flow::to_function::end::to_unqualified, r(p...)>::value, ObjectMemberFunction &>::type set(o *object, m function) Z_NOTHROW { this->function = reinterpret_cast(function); this->object = reinterpret_cast(&object); return *this; } template Z_INLINE typename TypeIf< Type::is_class && Type::is_member_function_pointer && TypeIsSame::flow::to_function::end::to_unqualified, r(p...)>::value, ObjectMemberFunction &>::type set(const o &object, m function) Z_NOTHROW { this->function = reinterpret_cast(function); this->object = const_cast(reinterpret_cast(&object)); return *this; } }; } #endif #endif // Z_classes_ObjectMemberFunction_HPP