Boost logo

Boost :

From: Brock Peabody (brock.peabody_at_[hidden])
Date: 2003-10-14 17:37:39


> -----Original Message-----
> From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]]
> On Behalf Of Edward Diener
> Sent: Tuesday, October 14, 2003 5:17 PM
> To: boost_at_[hidden]
> Subject: [boost] Re: Re: Preprocessor Docs Comments

[...]
>
> What were you trying to do, and what did you find ?

I was trying to find a way to keep from writing N versions of
functions/templates when you need to have 0-N parameters:

   template <typename T0> struct t_0 {...};
   template <typename T0, typename T1> struct t_1 {...};

   ...

   template <typename T0, typename T1, ... typename Tn> struct t_n {...};

and

   template <typename T0> t_0<T0> f(T0) {...}
   template <typename T0, typename T1, t_1<T0,T1> f(T0,T1) {...}

   ...

   template <typename T0, typename T1, ... typename TN>
      t_n<T0,T1,... TN> f(T0,T1,... TN);

I ended up using CAT, ENUM, and ENUM_PARMS. Boost PP made my code much
shorter and easier to maintain.

> I don't know of anyone who believes the preprocessor is evil, although I
> know Mr. Stroustrup has sought to steer C++ away from its reliance on the
> preprocessor. If it is worth it producing a preprocessor library which is
> usable by others, it is worth it producing a decent roadmap of its use and
> functionality.

IMO almost any solution is better than copy + paste. Most of my reasons for
using it would go away if we had variable number of template parameters, and
typesafe variable number of function arguments. I think the "Motivation"
section of the documentation gives a pretty good rational for this use.
Maybe there are other common uses for Boost PP that aren't as well
documented.

Brock


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