dimanche 29 août 2021

Template of Ret ( Class::*member )( Args... )

What would the be within the comments to make

property( "prop", &Class::getter, &Class::setter );

compile? This is the definition of property

template< typename Class, 
          typename Get,
          typename Set,
          typename = std::enable_if< std::is_same< 
              Get,
              typename std::remove_cv< typename std::remove_reference< typename std::remove_pointer< Set >::type >::type >::type >::value
          > 
>
constexpr auto property (
    const char* name,
    reflection::function< /* Get ( Class::* )() */ > getter,
    reflection::function< /* Get ( Class::* )( Set ) */ > setter
) {
    return nullptr;
}

I'm working on a constexpr function as described here except I would like to pass a class method as the argument. The one detailed there is useful for lambdas but I am looking for a class member.

reflection::function is defined as

template< typename > class function;

template < typename Class, typename Ret, typename ... Args >
class function < Ret ( Class::* ) ( Args... ) > {
public:
    constexpr function( Ret ( Class::*method )( Args... ) ) {
    
    }

    /* impl */
    
};




Aucun commentaire:

Enregistrer un commentaire