On Thu, 29 Mar 2012 14:39:20 +0100, Rob Desbois wrote:
I'm unable to use the reentrant macros for iteration currently..I think I'm probably misunderstanding their usage, and a push in the right direction would be much appreciated.
My need is to iterate through a sequence, then iterate through a sequence nested within each element. As I understand, I should be able to call (e.g.): * BOOST_PP_SEQ_FOR_EACH(OP, data, seq) to iterate through the outer sequence * then in OP(r, data, elem) call BOOST_PP_SEQ_FOR_EACH_R(r, OP2, data, elem)
Neither BOOST_PP_SEQ_FOR_EACH nor BOOST_PP_SEQ_TRANSFORM are reentrant
algorithms. In fact, only a relative few of the core algorithms in the pp-
lib are reentrant. In the cases of SEQ_FOR_EACH and SEQ_TRANSFORM, the
SEQ_FOR_EACH_R and SEQ_TRANSFORM_S variants of those macros reenter
BOOST_PP_FOR and BOOST_PP_SEQ_FOLD_LEFT efficiently. They do not reenter
SEQ_FOR_EACH and SEQ_TRANSFORM.
Unfortunately, it isn't realistic to implement everything in a reentrant
way (i.e. explosion of # of macros).
With Chaos--which requires a really good preprocessor (such as gcc)--
rather than the Boost.Preprocessor), all higher-order algorithms are
reentrant. E.g.
// 1.cpp
#include