I'm doing some metaprogramming and right now I need to test if a member function of a given type is callable with a given set of arguments, so I'm doing something like the following (which is heavily simplified by removing everything not important for this particular problem of course):
template<typename T, typename... Args>
struct argument_tester {
struct base: public T {
using T::my_member;
no my_member(...){}
};
typedef decltype(static_cast<base*>(0)->my_member(*static_cast<Args*...>(0))) type;
//verify return type
};
Of course it doesn't work with *static_cast<Args*...>(0), so my question is whether there is any way to unpack a parameter pack as dereferenced null pointers or if this is a case where I have to specialize for each number of arguments. And of course if there is a way how I would do that? I'm using gcc 4.6 in case that makes a difference for what's possible and what isn't.
The ... unpack "operator" can be placed outside the expression, in which case the expression is expanded.
The solution would thus be, I think, (*static_cast<Args*>(0))....
EDIT: Following R. Martinho Fernandes' hint
typedef decltype(std::declval<base>().my_member(std::declval<Args>()...)) type;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With