Boost logo

Boost Users :

From: Daniel James (daniel_james_at_[hidden])
Date: 2008-06-19 06:35:42


2008/6/18 Chris Fairles <chris.fairles_at_[hidden]>:
>
> I'm wrong. It's correctly erroring because:
> #elif 0 && () == 1
> isn't a valid constant expression.

If BOOST_PP_ITERATION_DEPTH was not defined that would probably be:

#elif 0 && BOOST_PP_ITERATION_DEPTH() == N

Which I think still isn't valid.

The basic structure of boost/mpl/aux_/advance_backward.hpp is something like:

#if !defined(BOOST_PP_IS_ITERATING)
// ...
#elif BOOST_PP_ITERATION_DEPTH() == 1
// ...
#elif BOOST_PP_ITERATION_DEPTH() == 2
// ...
#endif

If I understand you correctly, gcc 4.4 has started evaluating the
'#elif' arguments even when a previous '#if' or '#elif' argument was
true. I have no idea if gcc 4.4 is correct....

Your patch changes this to:

#if !defined(BOOST_PP_IS_ITERATING)
// ...
#elif defined(BOOST_PP_ITERATION_DEPTH)
# if BOOST_PP_ITERATION_DEPTH() == 1
// ...
# endif
#elif defined(BOOST_PP_ITERATION_DEPTH)
# if BOOST_PP_ITERATION_DEPTH() == 2
// ...
# endif
#endif

Which is wrong because the check 'BOOST_PP_ITERATION_DEPTH() == 2' can
never be reached. A solution might be something like:

#if !defined(BOOST_PP_IS_ITERATING)
// ...
#else
# if BOOST_PP_ITERATION_DEPTH() == 1
// ...
# elif BOOST_PP_ITERATION_DEPTH() == 2
// ...
# endif
#endif

Anyway, I doubt the relevant developers will see this. The best way to
get their attention would probably be to create a ticket:

http://svn.boost.org/trac/boost/newticket?component=mpl

Daniel


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