good to know! but I still get an error, on this new version.
error: no matching function for call to ‘test(<unresolved overloaded function type>)’
/tmp/tt.cpp:25:6: note: candidate is: void test(F) [with F = char (csquare_impl::*)(char)const]
but "run" is not overloaded !, and I don't know how to cast to resolve the overload.
#include <typeinfo>
#include <iostream>
#include <boost/type_traits/function_traits.hpp>
#include <boost/type_traits/remove_pointer.hpp>
#include <boost/function_types/parameter_types.hpp>
#include <boost/mpl/vector.hpp>
#include <boost/mpl/int.hpp>
#include <boost/mpl/at.hpp>
using namespace std;
double dsquare(double l){ return l*l; }
int isquare(int l){ return l*l; }
struct csquare_impl{
char run(char c) const{return 'c';}
};
csquare_impl csquare;
template<class F>
void test(F f){
// works
// typename boost::function_traits<typename boost::remove_pointer<F>::type>::arg1_type test_var;
// works too, more elegant(?)
typename boost::mpl::at_c<typename boost::function_types::parameter_types<F>::type, 0 >::type test_var;
cout << typeid(test_var).name() << endl;
}
int main(){
test(dsquare); // ok, prints "d"(double)
test(isquare); // ok, prints "i"(int)
test(csquare.csquare_impl::run); // not ok, want to print "c"(char)
return 0;
}
BTW, this type traits is a mess, everything it is all over the place, Boost.FunctionTypes, Boost.TypeTraits.FunctionTraits, Boost.Functional.