|
Boost Users : |
From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-06-18 16:03:24
Server Levent Yilmaz wrote:
>
>
> On 6/18/07, *Tobias Schwinger* <tschwinger_at_[hidden]
> <mailto:tschwinger_at_[hidden]>> wrote:
>
> Roman Perepelitsa wrote:
> > Tobias Schwinger <tschwinger <at> isonews2.com
> <http://isonews2.com>> writes:
> >
> >> Yep, here's another dirty trick :
> >>
> >> #include <boost/preprocessor/detail/is_unary.hpp>
> >>
> >> #define SPECIAL (whatever)
> >> #define IS_SPECIAL BOOST_PP_IS_UNARY
> >>
> >> IS_SPECIAL(a) // 0
> >> IS_SPECIAL(b) // 0
> >> IS_SPECIAL(SPECIAL) // 1
> >>
> >> It isn't entirely portable to older preprocessors (that's why
> this code
> >> lives in preprocessor/detail) but should work with latest
> versions of
> >> the widely-used compilers.
> >
> > This also works:
> >
> > #include <boost/preprocessor/facilities/is_empty.hpp>
> > #include <boost/preprocessor/empty.hpp>
> >
> > #define SPECIAL
> > #define IS_SPECIAL(x) BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY() x)
> >
>
> Yep, that's even better as it allows x to be anything. Got some idea how
> portable it is?
>
> Well, IS_UNARY trick also works for pretty much anything except maybe
> another non-SPECIAL unary.
Or a non-SPECIAL non-unary tuple, e.g. (foo,bar).
> What exactly is the offending code in BOOST_PP_IS_UNARY that makes it
> non-portable?
IIRC, there is no offending code - just some deficient preprocessor
implementations around that can't handle it...
Regards,
Tobias
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net