Boost logo

Boost :

From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2002-06-26 00:25:15


> I see what you mean - it would probably be more trivial to implement than my
> escaped #cmds method. (and hence easier to persuade "those-that-be").
>
> Macros *are* evil, yet sometimes there is just is no solution but to use
> them, so when you are forced to use them it would be nice if their feature
> set was just that little more complete. They (cpp steering committee?) took
> far too long to even implement the "new" __VA_ARGS__ feature, a feature I
> have been using in gcc since around 1993.

Macros are 'basically good' just misused. <-- :) Some things C++ proper cannot
do without comprising the whole system and only supporting special cases.

Unfortunately again, I can't use __VA_ARGS__ in C++. Hopefully, *they* will add
this in C++0x, but with the preprocessor, it's anybody's guess.

It is possible with __VA_ARGS_ (in combination with a little
template-metaprogramming) to implement overloaded classes. I have already
implemented this for things like Loki's Typelist. Right now, (without
__VA_ARGS__) we have three possibilities:

TYPELIST_3(int, int, int)

TYPELIST((int, int, int))

Variadic macros could reduce the last to:

TYPELIST(int, int, int)

Of course, we have the C++ alternative:

typelist<class A, class B = null_t, class C = null_t> // etc.

But then you have to bother with checking against null_t, etc..

> To bring it back to the boost newsgroup :-) imagine how much simpler the
> BOOST_PP_INC/DEC set of macros would be eh?

Not simpler, but a *lot* shorter. :) More importantly, how much *faster*
arithmetic would be on some compilers (EDG anyone?).

Paul Mensonides


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk