Boost logo

Boost :

Subject: [boost] Suggested change to type_traits/function_traits
From: Joseph Garvin (joseph.h.garvin_at_[hidden])
Date: 2010-07-13 14:12:28

I only just now subscribed to this list so forgive me if this has been
suggested and rejected before.

Currently function_traits<F> exposes the argument types for F as
individual typedefs, arg1_type, arg2_type, etc. I think this could be
made more powerful with two changes:

1. First, change it to be 0 indexed, arg0_type should be first. This
is more consistent with the rest of boost and C++ in general.

2. Have an inner arg struct, templated over an integer indicating
which argument you want. So instead of:

typedef some_type arg0_type;
typedef some_other_type arg1_type;

You would have:

template<int i>
struct arg

struct arg<0>
   typedef some_type type;

struct arg<1>
   typedef some_other_type type;

// etc.

I think this would make function_traits more usable for
metaprogramming. As is, to access the different argN_types you have to
resort to using boost preprocessor. For backwards compatibility the
old interface could co-exist with the new one.

Boost list run by bdawes at, gregod at, cpdaniel at, john at