From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-11-20 12:53:13
Andrei Alexandrescu wrote:
> You must be referring to the TYPELIST_nn macros.
> It's very simple. I don't give a rat's ass on the preprocessor and
> I'm fully aware of its vandalism. It's just that the set of
> requirements that I had for typelist "constructors" left the
> preprocessor as the only contender:
> 1. easy to use
> 2. scaleable up to more parameters
> (We can discuss separately whether or not these were good
> So I put together the nasty TYPELIST_1 to TYPELIST_50 and
> used them. I didn't notice name clashes etc., but I did notice an
> important shortcoming:
> 3. If you use a comma inside a macro, it won't work. Consider:
> typedef TYPELIST_2(vector<int, myallocator>, vector<int,
> that won't work because the preprocessor strongly believes
> that you actually passed four arguments to TYPELIST_2. What
> a nuisance. You can fix that by putting in place typedefs for
> those types.
> So it's a tradeoff issue. Any solution that fixes point 3
> fails on point 1, point 2, or (most often) both 1 and 2.
The below is copy & paste from "boost/mpl/test.cpp":
typedef mpl::type_list<int,char,long,short,char,long,double,long> types;
typedef mpl::find<types, short> types_find;
You can have as much as 128 parameters in a type_list :). Of course, I
cheated and used the Vesa Karvonen's PREPROCESSOR library internally :), but
before that I had my own stuff that did pretty much the same thing, so yes,
it's possible to satisfy all three criteria.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk