I need a type trait which will report the type of a functor\'s operator()
parameter given the type of the functor and the type of an argument passed to it. Basical
To get started I would go with this:
template
struct parameter_type_impl;
// may be with variadic arguments
template
struct parameter_type_impl {
typedef A type;
};
template
struct parameter_type {
typedef typename parameter_type_impl::type type;
};
I don't see why you would pass in the actual argument type. If the conversion is not able to take place you have to use special measures (e.g. SFINAE) later on. I think the two things are orthogonal: deducing the argument type, then deciding if the argument you would like to pass in is convertible.
The non-C++03 decltype is hard to get rid of. Specifying a function type always requires knowledge of the arguments. As soon as you would spell out the arguments, the whole thing would be moot.
The same problem would occur with Boost.Function Types
.