From: Dean Michael Berris (mikhailberis_at_[hidden])
Date: 2007-01-10 02:53:26
I was looking at the function_traits implementation in the Boost CVS,
and saw that it might benefit from adding a tuple-like interface to
the function_traits type. I'm thinking along the lines of:
typedef function_traits<void(int,char,bool)> sample_trait;
at_c<sample_trait::args, 1>::type a; // char
at_c<sample_trait::args, 3>::type b; // error, out of bounds ?
typedef function_traits<void( tuple<int, char, bool> , std::string )>
at< typename at_c<another_sample::args, 0>::type, 0 >::type c; // int
Perhaps adding a mpl::vector or a fusion::vector element 'args' can
greatly improve the kinds of things that can be done with the
function_traits<>, especially in libraries aiming to become more
flexible when it comes to argument pack handling.
I got the idea because I found myself needing a generic way of
defining a tuple from the argument list of a signatures passed to
function_traits<>. That's a pretty simple use case, but I found myself
having to do some repetitive overloads to accommodate the 10
variations of function_traits using just the function_traits<>::arity
element, and then having to do PP magic to iterate through the
With the additional `args' fusion/mpl vector in function_traits<>, it
wouldn't have to be a concern since it already packs the types of the
arguments. Defining operations over args could very well be a simple
exercise in template metaprogramming.
If anybody's interested, it's a pretty trivial patch attached.
-- Dean Michael C. Berris http://cplusplus-soup.blogspot.com/ mikhailberis AT gmail DOT com +63 928 7291459
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk