mercredi 19 octobre 2016

decltype for overloaded member function

I have this code:

struct Foo 
{
    int print(int a, double b);
    int print(int a);
    void print();
    void print(int a, int b, inc c);

    void other();
};

I can call

decltype(&Foo::other)

but calling

decltype(&Foo::print)

end with error, which is clear to me.

But how can I specify more "closely" which of the four print methods, I want to resolve to decltype?

I want to further use this in

template <class MT>
struct method_info;

template <class T, class Res, class... Args>
struct method_info<Res(T::*)(Args...)>
{
    typedef std::tuple<Args&&...> args_tuple;
    typedef T ClassType;
    typedef Res RetVal; 
};



template <class MethodType>
void func() {
   typedef method_info<MethodType> MethodInfo;
   .....
}

func<decltype(&Foo::other)>();
....

Aucun commentaire:

Enregistrer un commentaire