/* Zeta API - Z/classes/MemberFunction.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_MemberFunction_HPP #define Z_classes_MemberFunction_HPP #include #if Z_DIALECT_HAS(CPP98, SFINAE) && \ Z_DIALECT_HAS(CPP11, VARIADIC_TEMPLATE) && \ Z_DIALECT_HAS(CPP11, DEFAULT_TEMPLATE_ARGUMENTS_FOR_FUNCTION_TEMPLATE) # define Z_HAS_MemberFunction 1 # include # include namespace Zeta { template struct MemberFunction; template struct MemberFunction { r (NaT::* function)(p...); Z_INLINE MemberFunction() Z_NOTHROW Z_DEFAULTED({}) # ifdef Z_NULLPTR Z_CT(CPP11) MemberFunction(NullPtr) Z_NOTHROW : function(nullptr) {}; # endif template ::is_member_function_pointer && TypeIsSame::flow::to_function::end::to_unqualified, r(p...)>::value >::type> Z_INLINE MemberFunction(m function) Z_NOTHROW : function(reinterpret_cast(function)) {} Z_CT(CPP11) operator Boolean() const Z_NOTHROW {return function != Z_NULL;} template ::is_member_function_pointer && TypeIsSame::flow::to_function::end::to_unqualified, r(p...)>::value >::type> Z_INLINE operator m() const Z_NOTHROW {return reinterpret_cast(function);} template Z_INLINE typename TypeIf< Type::is_member_function_pointer && TypeIsSame::flow::to_function::end::to_unqualified, r(p...)>::value, MemberFunction &>::type operator =(m rhs) Z_NOTHROW { function = reinterpret_cast(rhs); return *this; } template Z_INLINE r operator ()(o *object, typename Type

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

::to_forwardable... arguments) const {return (const_cast(reinterpret_cast(&object))->*function)(arguments...);} }; } #endif #endif // Z_classes_MemberFunction_HPP