Boost logo

Boost :

From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2003-04-11 22:25:17


Paul Mensonides wrote:
> Aleksey Gurtovoy wrote:
>
> >> // custom user-defined macros:
> >> #define _COMPARE_Aleksey(x) x
> >> #define _COMPARE_Paul(x) x
> >>
> >> _COMPARE(abc, Aleksey) // 0
> >> _COMPARE(Paul, Aleksey) // 0
> >> _COMPARE(Aleksey, abc) // 0
> >> _COMPARE(Aleksey, Aleksey) // 1
> >
> > That's exactly the facility I would be completely happy with!
>
> Notice the cool manipulation involved:
>
> #define A(x) x
> #define B(x) x
>
> A( B )( () ) // expands to: ()
> B( A )( () ) // expands to: ()
> A( A )( () ) // expands to: A( () )
> B( B )( () ) // expands to: B( () )
>
> This is fundamental idiom at work here.

Witty!

> > Can we make it work for some of the broken preprocessors?
> > Personally, I care only about MSVC and Metrowerks.
>
> Actually it might be possible for those two, which are "evil"
> in general. However, it won't work in many cases on preprocessor's
> that use the Borland configuration, because they have trouble with
> the IS_NULLARY detection.
>
> If you want, try it out "as is". All those facilities are
> already in the CVS pp-lib.

Yep, it works! Say, why don't we provide some library primitive along the
lines of your _COMPARE snippet, e.g. BOOST_PP_TOKEN_EQUAL? I am sure the
users that don't care about those broken compilers would appreciate it. I
would even provide a test case for it (already wrote it anyway :).

Aleksey


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