reinserted delay macros

[SVN r14171]
This commit is contained in:
Paul Mensonides
2002-06-18 21:54:30 +00:00
parent 6a7259a48d
commit 37f823fd4a
3 changed files with 21 additions and 8 deletions

View File

@ -13,7 +13,9 @@
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/detail/cat.hpp>
// pm: not necessary if using manual delay
// #include <boost/preprocessor/detail/cat.hpp>
#include <boost/preprocessor/logical/bool.hpp>
/** <p>Expands to <code>EXPR</code> if <code>COND != 0</code> and to nothing if <code>COND == 0</code>.</p>
@ -27,7 +29,10 @@
<li>BOOST_PP_IF()</li>
</ul>
*/
#define BOOST_PP_EXPR_IF(COND,EXPR) BOOST_PP_DETAIL_CAT2(BOOST_PP_EXPR_IF,BOOST_PP_BOOL(COND))(EXPR)
#define BOOST_PP_EXPR_IF(COND,EXPR) BOOST_PP_EXPR_IF_BOOL(BOOST_PP_BOOL(COND),EXPR) // original: BOOST_PP_DETAIL_CAT2(BOOST_PP_EXPR_IF,BOOST_PP_BOOL(COND))(EXPR)
#define BOOST_PP_EXPR_IF_BOOL(COND,EXPR) BOOST_PP_EXPR_IF_BOOL_DELAY(COND,EXPR)
#define BOOST_PP_EXPR_IF_BOOL_DELAY(COND,EXPR) BOOST_PP_EXPR_IF##COND(EXPR)
#define BOOST_PP_EXPR_IF0(E)
#define BOOST_PP_EXPR_IF1(E) E

View File

@ -13,7 +13,9 @@
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/detail/cat.hpp>
// pm: not necessary if using manual delay
// #include <boost/preprocessor/detail/cat.hpp>
#include <boost/preprocessor/logical/bool.hpp>
/** <p>Expands to <code>THEN</code> if <code>COND != 0</code> and <code>ELSE</code> if
@ -33,7 +35,11 @@
<li><a href="../../test/preprocessor_test.cpp">preprocessor_test.cpp</a></li>
</ul>
*/
#define BOOST_PP_IF(COND,THEN,ELSE) BOOST_PP_DETAIL_CAT2(BOOST_PP_IF,BOOST_PP_BOOL(COND))(ELSE,THEN)
#define BOOST_PP_IF0(E,T) E
#define BOOST_PP_IF1(E,T) T
#define BOOST_PP_IF(COND,THEN,ELSE) BOOST_PP_IF_BOOL(BOOST_PP_BOOL(COND),THEN,ELSE) // original: BOOST_PP_DETAIL_CAT2(BOOST_PP_IF,BOOST_PP_BOOL(COND))(ELSE,THEN)
#define BOOST_PP_IF_BOOL(COND,THEN,ELSE) BOOST_PP_IF_BOOL_DELAY(COND,THEN,ELSE)
#define BOOST_PP_IF_BOOL_DELAY(COND,THEN,ELSE) BOOST_PP_IF##COND(THEN,ELSE)
#define BOOST_PP_IF0(T,E) E // BOOST_PP_IF0(E,T) E
#define BOOST_PP_IF1(T,E) T // BOOST_PP_IF1(E,T) T
#endif

View File

@ -13,7 +13,8 @@
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/detail/cat.hpp>
// pm: not necessary if using manual delay
// #include <boost/preprocessor/detail/cat.hpp>
/** <p>Expands to <code>0</code> if <code>X == 0</code> and <code>1</code> if <code>X != 0</code>.</p>
@ -21,7 +22,8 @@
<p>For example, <code>BOOST_PP_BOOL(3)</code> expands to <code>1</code>.</p>
*/
#define BOOST_PP_BOOL(X) BOOST_PP_DETAIL_CAT2(BOOST_PP_BOOL,X)
#define BOOST_PP_BOOL(X) BOOST_PP_BOOL_DELAY(X) // original: BOOST_PP_DETAIL_CAT2(BOOST_PP_BOOL,X)
#define BOOST_PP_BOOL_DELAY(X) BOOST_PP_BOOL##X
/* BOOL can be implemented in O(1) tokens using saturated ADD & SUB.
* Unfortunately, it would result in significantly slower preprocessing.