[Boost-bugs] [Boost C++ Libraries] #4456: BOOST_PP_SEQ_FOLD_RIGHT completely broken

Subject: [Boost-bugs] [Boost C++ Libraries] #4456: BOOST_PP_SEQ_FOLD_RIGHT completely broken
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2010-07-20 17:39:54


#4456: BOOST_PP_SEQ_FOLD_RIGHT completely broken
----------------------------+-----------------------------------------------
 Reporter: ookami1@… | Owner: no-maintainer
     Type: Bugs | Status: new
Milestone: Boost 1.44.0 | Component: preprocessor
  Version: Boost 1.44.0 | Severity: Problem
 Keywords: |
----------------------------+-----------------------------------------------
 The following program is adapted from the macro BOOST_PP_SEQ_CAT that
 concatenates the elements of a sequence to a string:

 (a)(b)(c)(d) ==> "abcd"

 BOOST_PP_SEQ_CAT is built upon BOOST_SEQ_FOLD_LEFT; by analogy, one would
 expect that macro REVCAT, written after BOOST_PP_SEQ_CAT, but using
 BOOST_PP_SEQ_FOLD_RIGHT, builds a reversed string "dcba". This is not the
 case, in fact, the program does not even compile, because
 BOOST_PP_FOLD_RIGHT is currently completely broken.


 {{{
 #include <boost/preprocessor.hpp>
 # define REVCAT(seq) \
     BOOST_PP_IF( \
         BOOST_PP_DEC(BOOST_PP_SEQ_SIZE(seq)), \
         REVCAT_I, \
         BOOST_PP_SEQ_HEAD(seq) BOOST_PP_TUPLE_EAT_1 \
     )(seq) \
     /**/
 # define REVCAT_I(seq) BOOST_PP_SEQ_FOLD_RIGHT(REVCAT_O,
 BOOST_PP_SEQ_HEAD(seq), BOOST_PP_SEQ_TAIL(seq))
 #
 # define REVCAT_O(s, st, elem) REVCAT_O_I(st, elem)
 # define REVCAT_O_I(a, b) a ## b

 const char x[] = BOOST_PP_STRINGIZE(BOOST_PP_SEQ_CAT((a)(b)(c)(d)));
 # pragma warning just a marker
 const char revx[] = BOOST_PP_STRINGIZE(REVCAT((a)(b)(c)(d)));
 }}}


 int main() { return *x == 0; }

 Here is the message from the compiler:

 Invoking: GCC C++ Compiler
 g++ -I"/home/wolf/workspace/booster" -O0 -g3 -Wall -c -fmessage-length=0
 -MMD -MP -MF"booster.d" -MT"booster.d" -o"booster.o" "../booster.cpp"
 ../booster.cpp:15: warning: ignoring #pragma warning just
 ../booster.cpp:16:1: error: macro "BOOST_PP_SEQ_ELEM_III" requires 2
 arguments, but only 1 given

 Note that the first call succeeds.

 Cheers

 Wolf Lammen

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/4456>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:03 UTC