It works just fine, for plain vanilla functions. The code below works just fine. It prints just what is should:
int __cdecl(int, char)
2
int,char
#include <boost/type_traits.hpp>
#include <boost/function.hpp>
#include <boost/typeof/std/utility.hpp>
#include <iostream>
using std::cout;
using std::endl;
int foo(int, char) {
return 0;
}
int main() {
typedef BOOST_TYPEOF(foo) foo_type;;
typedef boost::function_traits<foo_type> function_traits;
cout << typeid(foo_type).name() << endl;
cout << function_traits::arity << endl;
cout << typeid(function_traits::arg1_type).name() << ",";
cout << typeid(function_traits::arg2_type).name() << endl;
return 0;
}
So, the question is, how can one do this if foo is a member function of class bar?
struct bar {
int foo(int, char) { return 0; }
};
I have tried countless combinations of these constructs: BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() BOOST_TYPEOF_REGISTER_TYPE() boost::ref boost::remove_pointer boost::bind boost::mem_fn
etc., etc... No joy.
Kornel Kisielewicz nailed it. Here it is with the solution separated from the test-messages.
Boost Function Types would probably be the natural solution: