Opened 12 years ago
Closed 12 years ago
#4456 closed Bugs (invalid)
BOOST_PP_SEQ_FOLD_RIGHT completely broken
Reported by: | Owned by: | No-Maintainer | |
---|---|---|---|
Milestone: | Boost 1.44.0 | Component: | preprocessor |
Version: | Boost 1.44.0 | Severity: | Problem |
Keywords: | Cc: |
Description
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
Change History (2)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
Today a had a look again at fold_right.hpp to see why it failed a few days ago. To my great surprise, I was unable to reproduce the error. I do not know what has happened, but right now, everything works fine.
I am going to mark this as invalid.
Cheers
Wolf Lammen