Boost logo

Boost :

From: vesa_karvonen (vesa.karvonen_at_[hidden])
Date: 2002-01-16 08:37:48

I'd like to hear suggestions for naming a new repetition primitive to
be added to the preprocessor library. Currently I've named the
primitive as BOOST_PP_REPEAT_WHILE(), but I'd like to hear other
suggestions. The primitive is basically a generalization of

#define BOOST_PP_REPEAT_WHILE(C,F,I,X) /* ... */

  X = State
  C(D,X) = condition to check if repetition should be continued
  F(D,X) = transform from state(n) to state(n+1)
  I(D,X) = instantiate state
  D = repetition depth (for invoking BOOST_PP_REPEAT_WHILE)

Consider the following trivial example:

  #define C(D,X) BOOST_PP_LESS(X,4)
  #define F(D,X) BOOST_PP_INC(X)
  #define I(D,X) X


The above expands to:

  0 1 2 3

The above can easily be done using BOOST_PP_REPEAT(), but the ability
to arbitrarily transform the state makes it possible to enumerate a
list (data structure) in O(N) time instead of O(N*N) time.

Boost list run by bdawes at, gregod at, cpdaniel at, john at