|
Boost : |
From: Paul Mensonides (pmenso57_at_[hidden])
Date: 2005-03-02 06:21:33
> -----Original Message-----
> From: boost-bounces_at_[hidden]
> [mailto:boost-bounces_at_[hidden]] On Behalf Of Edward Bishop
> My question is, how can I eliminate the warning. Thanks in
> advance for any comments/advice.
>
>
> # include <boost/preprocessor/library.hpp>
>
> #define IS_SIMPLE(t) BOOST_PP_NOT_EQUAL(3, BOOST_PP_SEQ_SIZE(t))
> #define PROPERTIES(t) BOOST_PP_SEQ_ELEM(2,t)
> #define HAS_COLOR(t) BOOST_PP_EQUAL(2, BOOST_PP_SEQ_ELEM(0, \
> PROPERTIES(t)))
> #define COLOR(t) BOOST_PP_SEQ_ELEM(1, PROPERTIES(t))
>
>
> #define FSIMPLE(a, s, i, t) \
> BOOST_PP_SEQ_ELEM(0,t) is simple;
>
> #define FCOMPLEX(a, s, i, t) \
> BOOST_PP_SEQ_ELEM(0,t) is complex \
> BOOST_PP_IF(HAS_COLOR(t), and color is COLOR(t) , );
^^^
This is undefined behavior in C++. Should be:
#define FCOMPLEX(a, s, i, t) \
BOOST_PP_SEQ_ELEM(0,t) is complex \
BOOST_PP_EXPR_IF(HAS_COLOR(t), and color is COLOR(t)); \
> #define FCHOICE(a, s, i, t) \
> BOOST_PP_IF(IS_SIMPLE(t), \
> FSIMPLE(a, s, i, t), \
> FCOMPLEX(a, s, i, t))
The IF here is not lazy. Both the true and false cases are being evaluated, but
then one is discarded. Should be:
#define FCHOICE(a, s, i, t) \
BOOST_PP_IF(IS_SIMPLE(t), FSIMPLE, FCOMPLEX)(a, s, i, t)
Regards,
Paul Mensonides
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk