|
Boost Users : |
From: Ed Keith (e_d_k_at_[hidden])
Date: 2008-05-06 12:00:21
--- 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 not got it working yet, but I think I can avoid
the combinatorial explosion.
For each token 'foo', I define 'X_foo' and give it a
uneque numeric value. Then I can use the following to
compare them :
#define MY_COMPARE(x,y)
BOOST_PP_EQUAL(BOOST_PP_CAT(X_, x),
BOOST_PP_CAT(X_,y))
Still not a elegant as I'd like, but no combinatorial
explosion.
Thanks a lot for putting me on the right track.
-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