Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2006-12-22 09:26:02


Hi,

Would it be possible to add BOOST_PP_RESET_COUNTER() macro.
The effect is to reset BOOST_PP_COUNTER to zero.

These lines of code can do the job:
#undef BOOST_PP_COUNTER
#define BOOST_PP_COUNTER 0

There are several uses of this facility. For example I want
to be sure, that the counter starts at zero when I use it
first time in my header, regardless of the other inclusions.

Implementation can be similar to BOOST_PP_UPDATE_COUNTER().

new file boost/preprocessor/slot/detail/reset_counter.hpp:

#undef BOOST_PP_COUNTER
#define BOOST_PP_COUNTER 0

new macro in boost/preprocessor/slot/counter.hpp:

#define BOOST_PP_RESET_COUNTER \
<boost/preprocessor/slot/detail/reset_counter.hpp>

usage:

#include <boost/preprocessor/slot/counter.hpp>
BOOST_PP_COUNTER // 0
#include BOOST_PP_UPDATE_COUNTER()
BOOST_PP_COUNTER // 1
#include BOOST_PP_UPDATE_COUNTER()
BOOST_PP_COUNTER // 2

#include BOOST_PP_RESET_COUNTER()
BOOST_PP_COUNTER // 0

Regards,
Pavol


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk