In article <11************ **********@s48g 2000cws.googleg roups.com>,

<ps*****@gmail. comwrote:

Hi everybody,

int f(int a, int b) { return a + b; };

is it possible to obtain this function signature - int (int, int) in

this case - for use in boost::function _traits ?

e.g. std::cout << "f's arity : " << boost::function _traits<*obtain ing

signature from f()*>::arity << std::endl;

please no macro solutions - only C++ (Boost MPL maybe could be useful

- but still don't see how)

best regards, Paul Sujkov

template <class Tstruct function_arity;

template <class R>

struct function_arity< R(){static const int value = 0;};

// for N=1..N_max do

template <class R,class T1>

struct function_arity< R(T1){static const int value = 1;};

template <class R,class T1,class T2>

struct function_arity< R(T1,T2){static const int value = 2;};

// etc.

boost's preprocessor library can be used to automate this, but

you said no preprocessor stuff.

using boost function [which uses the preprocessor :)]

template <class Fstruct function_arity

{

static const int value = boost::function <F>::arity;

};

but tr1::function does not provide this.

--

[ See

http://www.gotw.ca/resources/clcm.htm for info about ]

[ comp.lang.c++.m oderated. First time posters: Do this! ]