0

Given some_type with a member function f it is possible to determine f's signature like this (and say let us place it in a tuple):

template <typename R, typename T, typename... A>
std::tuple<R, A...> signature_of_impl(R (T::*)(A...));

template <typename T>
using signature_of_member_f = decltype(signature_of_impl(&T::f));

struct some_type
{
    int f(char, float);
};

using some_type_f_signature = signture_of_member_f<some_type>;

This obviously fails badly if f is overloaded. Is it possible to determine signatures of all existing overloads of f within some_type?

yuri kilochek
  • 12,709
  • 2
  • 32
  • 59

1 Answers1

0

You can "ask" the compiler for the type of a specific function.

But there's no reflection in C++, you can't query what functions or even overloads of the same function exist in a class.

Yochai Timmer
  • 48,127
  • 24
  • 147
  • 185
  • Reflection implies run-time queries, I want compile-time ones. C++ allows to do things that seem impossible at first in complicated roundabout ways. I was hoping for such a possibility. – yuri kilochek Feb 01 '13 at 15:58
  • True, but still the compiler "tricks" to get information about a class are always explicit. Even SFINAE required you to be explicit so SFINAE can happen and the right type is chosen and set. – Yochai Timmer Feb 01 '13 at 16:01