|
Boost : |
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2002-05-12 18:04:26
> > But that only says how many parameters there are not there types. Using
> the
> > sizeof trick won't work for a complete function_traits class.
> >
> > Paul Mensonides
>
> Very true. But as was said to me earlier in this thread, for some function
> objects
> not all the parameter types can be determined. (Some results of a
> boost::bind for
> instance.)
>
> Dirk Gerrits
BTW, I already have my own full-fledge function_traits implementation, but it
uses my own preprocessor library to generate it, so I haven't post it. However,
all of these things work:
typedef function_traits<void (int, int, double)> a;
std::cout
<< typeid(a::return_type).name() << '\n' // void
<< a::has_ellipsis << '\n' // false
<< a::arity << '\n' // 3
<< typeid(a::parameter<0>::type).name() << &std::endl; // int
typedef function_traits<void (*)(...)> b;
std::cout
<< typeid(b::return_type).name() << '\n' // void
<< b::has_ellipsis << '\n' // true
<< b::arity << '\n' // 0
typedef function_traits<double (&)(void)> c;
std::cout
<< typeid(c::return_type).name() << '\n' // double
<< c::has_ellipsis << '\n' // false
<< c::arity << '\n' // 0
typedef function_traits<int (X::*)(int, short) const> d;
std::cout
<< typeid(d::return_type).name() << '\n' // int
<< d::has_ellipsis << '\n' // false
<< typeid(d::member_of).name() << '\n' // X
<< d::is_const << '\n' // true
<< d::arity << '\n' // 2
<< typeid(d::parameter<1>::type).name() << &std::endl; // short
// etc.
I was just wondering what other things are required that I may have missed.
Paul Mensonides
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk