Boost logo

Boost :

From: Christoph Ludwig (cludwig_at_[hidden])
Date: 2004-08-13 02:45:55


On Thu, Aug 12, 2004 at 07:03:57PM -0700, Paul Mensonides wrote:
> > From: boost-bounces_at_[hidden]
> > [mailto:boost-bounces_at_[hidden]] On Behalf Of Rene Rivera
>
> > [snip]
> > > a look at the preprocessor library but I couldnt come up with a
> > > solution. Is there an alternative to the macros for
> > registering types?
> > > (A sample program exhibiting what I am trying is attached.)
> > [snip]
> > > // Doesn't work (wrong number of macro arguments ):
> > > // BOOST_CLASS_EXPORT( DerivedStatus< Algo< int, double > > );
> >
> > Did you try using BOOST_PP_COMMA ?? For example:
> >
> > BOOST_CLASS_EXPORT( DerivedStatus< Algo< int BOOST_PP_COMMA
> > double > > );
>
> Should be with nullary parentheses:
>
> BOOST_CLASS_EXPORT( DerivedStatus< Algo<int BOOST_PP_COMMA() double > > );
>
[...]
> The COMMA() trick will only work through one level of macro
> expansion.

Unfortunately, the serialization lib's export macros go through
several levels. Therefore, replacing the commas by BOOST_PP_COMMA()
does not help. (I tried it a few minutes ago.)

> Incidently, do we have a function argument mapping for the common case of this
> type of thing?
>
> E.g.
>
> template<class> struct pack;
>
> template<class T> struct pack<void (T)> {
> typedef T type;
> };
>
> BOOST_CLASS_EXPORT( pack<void (DerivedStatus< Algo<int, double > >)>::type );

That did the trick! Great!

I am not sure which of Boost's libraries is the most adequate place
for such a tool (preprocessor? mpl?), but it is certainly
valuable. And if / once there is such a tool in Boost, then the
documentation of macros that are likely to take classes genareted
from templates as arguments should refer to it.

Regards

Christoph

-- 
http://www.informatik.tu-darmstadt.de/TI/Mitarbeiter/cludwig.html
LiDIA: http://www.informatik.tu-darmstadt.de/TI/LiDIA/Welcome.html

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