Boost logo

Boost Users :

From: Ed Keith (e_d_k_at_[hidden])
Date: 2008-05-06 11:04:54


--- Joel Falcou <joel.falcou_at_[hidden]> wrote:
> >
> > I have two sequences. Both represent sets, one is
> a
> > subset of the other. What I want to do is for each
> > element in the superset, generate one value if it
> is
> > in the subset, and another value if it is not in
> the
> > subset. The problem is that the elements are not
> > numeric (they are just tokens), so I can not seem
> to
> > compare them to determine if they are the same.
> >
> > Any sugestions?
>
> What I woukld write is borrowed from the inner
> mechanics of Boost::PP.
> let's say you have two token FOO & BAR.
>
> #define IS_SAME_TOKEN_FOO_FOO 1
> #define IS_SAME_TOKEN_FOO_BAR 0
> #define IS_SAME_TOKEN_BAR_FOO 0
> #define IS_SAME_TOKEN_BAR_BAR 0
>
> #define IS_SAME_TOKEN(X,Y)
>
BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(IS_SAME_TOKEN_,X),_),Y)
>
> then use IS_SAME_TOKEN in BOOST_PP_IF
>
> I knwo it gets cumbersome as the number of tokens
> increase but I can't
> see hwo to do it better.

I have about a dozen tokens. Maybe I can automagicly
generate the defines. . .

I'll give it a try.

Thanks,

   -EdK

Ed Keith
e_d_k_at_[hidden]

Blog: edkeith.blogspot.com

      ____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


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