Using private detail CAT to avoid DELAY macros

[SVN r14147]
This commit is contained in:
Vesa Karvonen
2002-06-14 20:38:54 +00:00
parent 5e0488f509
commit 54d0da5221
10 changed files with 57 additions and 34 deletions

View File

@ -13,6 +13,8 @@
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/detail/cat.hpp>
/** <p>Decrements <code>X</code> expanding to a single token.</p>
<p>For example, <code>BOOST_PP_DEC(3)</code> expands to <code>2</code> (a
@ -23,9 +25,8 @@ single token).</p>
<p>Only decimal integer literals in the range [0,BOOST_PP_LIMIT_MAG] are
supported.</p>
*/
#define BOOST_PP_DEC(X) BOOST_PP_DEC_DELAY(X)
#define BOOST_PP_DEC(X) BOOST_PP_DETAIL_CAT2(BOOST_PP_DEC,X)
#define BOOST_PP_DEC_DELAY(X) BOOST_PP_DEC##X
#define BOOST_PP_DEC0 0
#define BOOST_PP_DEC1 0
#define BOOST_PP_DEC2 1

View File

@ -0,0 +1,25 @@
#ifndef BOOST_PREPROCESSOR_DETAIL_CAT_HPP
#define BOOST_PREPROCESSOR_DETAIL_CAT_HPP
/* Copyright (C) 2002 Vesa Karvonen
*
* Permission to copy, use, modify, sell and distribute this software is
* granted provided this copyright notice appears in all copies. This
* software is provided "as is" without express or implied warranty, and
* with no claim as to its suitability for any purpose.
*
* See http://www.boost.org for most recent version.
*/
#define BOOST_PP_DETAIL_CAT2(A,B) BOOST_PP_DETAIL_DO_CAT2(A,B)
#define BOOST_PP_DETAIL_DO_CAT2(A,B) A##B
#define BOOST_PP_DETAIL_CAT3(A,B,C) BOOST_PP_DETAIL_DO_CAT3(A,B,C)
#define BOOST_PP_DETAIL_DO_CAT3(A,B,C) A##B##C
#define BOOST_PP_DETAIL_CAT4(A,B,C,D) BOOST_PP_DETAIL_DO_CAT4(A,B,C,D)
#define BOOST_PP_DETAIL_DO_CAT4(A,B,C,D) A##B##C##D
#define BOOST_PP_DETAIL_CAT5(A,B,C,D,E) BOOST_PP_DETAIL_DO_CAT5(A,B,C,D,E)
#define BOOST_PP_DETAIL_DO_CAT5(A,B,C,D,E) A##B##C##D##E
#endif

View File

@ -13,6 +13,7 @@
* See http://www.boost.org for most recent version.
*/
#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>
@ -26,10 +27,8 @@
<li>BOOST_PP_IF()</li>
</ul>
*/
#define BOOST_PP_EXPR_IF(COND,EXPR) BOOST_PP_EXPR_IF_BOOL(BOOST_PP_BOOL(COND))(EXPR)
#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_BOOL(C) BOOST_PP_EXPR_IF_BOOL_DELAY(C)
#define BOOST_PP_EXPR_IF_BOOL_DELAY(C) BOOST_PP_EXPR_IF_BOOL##C
#define BOOST_PP_EXPR_IF_BOOL0(E)
#define BOOST_PP_EXPR_IF_BOOL1(E) E
#define BOOST_PP_EXPR_IF0(E)
#define BOOST_PP_EXPR_IF1(E) E
#endif

View File

@ -13,6 +13,7 @@
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/detail/cat.hpp>
#include <boost/preprocessor/logical/bool.hpp>
#include <boost/preprocessor/tuple/elem.hpp>
@ -33,8 +34,5 @@
<li><a href="../../test/preprocessor_test.cpp">preprocessor_test.cpp</a></li>
</ul>
*/
#define BOOST_PP_IF(COND,THEN,ELSE) BOOST_PP_IF_BOOL(BOOST_PP_BOOL(COND))(ELSE,THEN)
#define BOOST_PP_IF_BOOL(C) BOOST_PP_IF_BOOL_DELAY(C)
#define BOOST_PP_IF_BOOL_DELAY(C) BOOST_PP_TUPLE2_ELEM##C
#define BOOST_PP_IF(COND,THEN,ELSE) BOOST_PP_DETAIL_CAT2(BOOST_PP_TUPLE2_ELEM,BOOST_PP_BOOL(COND))(ELSE,THEN)
#endif

View File

@ -13,6 +13,8 @@
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/detail/cat.hpp>
/** <p>Increments <code>X</code> expanding to a single token.</p>
<p>For example, <code>BOOST_PP_INC(3)</code> expands to <code>4</code> (a
@ -24,9 +26,8 @@ BOOST_PP_LIMIT_MAG yields a BOOST_PP_LIMIT_MAG.</p>
<p>Only decimal integer literals in the range [0,BOOST_PP_LIMIT_MAG] are
supported.</p>
*/
#define BOOST_PP_INC(X) BOOST_PP_INC_DELAY(X)
#define BOOST_PP_INC(X) BOOST_PP_DETAIL_CAT2(BOOST_PP_INC,X)
#define BOOST_PP_INC_DELAY(X) BOOST_PP_INC##X
#define BOOST_PP_INC0 1
#define BOOST_PP_INC1 2
#define BOOST_PP_INC2 3

View File

@ -45,8 +45,8 @@ prefix_A(0); prefix_B(1); prefix_C(2);
#define BOOST_PP_LIST_FOR_EACH_I(MACRO,DATA,LIST) BOOST_PP_LIST_FOR_EACH_I_R(0,MACRO,DATA,LIST)
/** <p>Can be used inside BOOST_PP_FOR() (see for an explanation of the R parameter).</p> */
#define BOOST_PP_LIST_FOR_EACH_I_R(R,MACRO,DATA,LIST) BOOST_PP_FOR##R((MACRO,DATA,LIST,0),BOOST_PP_LIST_FOR_EACH_I_C,BOOST_PP_LIST_FOR_EACH_I_F,BOOST_PP_LIST_FOR_EACH_I_I)
#define BOOST_PP_LIST_FOR_EACH_I_C(R,MDLI) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_TUPLE_ELEM(4,2,MDLI))
#define BOOST_PP_LIST_FOR_EACH_I_F(R,MDLI) (BOOST_PP_TUPLE_ELEM(4,0,MDLI),BOOST_PP_TUPLE_ELEM(4,1,MDLI),BOOST_PP_TUPLE_ELEM(3,1,BOOST_PP_TUPLE_ELEM(4,2,MDLI)),BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4,3,MDLI)))
#define BOOST_PP_LIST_FOR_EACH_I_I(R,MDLI) BOOST_PP_TUPLE_ELEM(4,0,MDLI)(R,BOOST_PP_TUPLE_ELEM(4,1,MDLI),BOOST_PP_TUPLE_ELEM(4,3,MDLI),BOOST_PP_TUPLE_ELEM(3,0,BOOST_PP_TUPLE_ELEM(4,2,MDLI)))
#define BOOST_PP_LIST_FOR_EACH_I_R(R,MACRO,DATA,LIST) BOOST_PP_FOR##R((MACRO,DATA,LIST,0),BOOST_PP_LIST_FOR_EACH_I_P,BOOST_PP_LIST_FOR_EACH_I_O,BOOST_PP_LIST_FOR_EACH_I_M)
#define BOOST_PP_LIST_FOR_EACH_I_P(R,MDLI) BOOST_PP_TUPLE_ELEM(3,2,BOOST_PP_TUPLE_ELEM(4,2,MDLI))
#define BOOST_PP_LIST_FOR_EACH_I_O(R,MDLI) (BOOST_PP_TUPLE_ELEM(4,0,MDLI),BOOST_PP_TUPLE_ELEM(4,1,MDLI),BOOST_PP_TUPLE_ELEM(3,1,BOOST_PP_TUPLE_ELEM(4,2,MDLI)),BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(4,3,MDLI)))
#define BOOST_PP_LIST_FOR_EACH_I_M(R,MDLI) BOOST_PP_TUPLE_ELEM(4,0,MDLI)(R,BOOST_PP_TUPLE_ELEM(4,1,MDLI),BOOST_PP_TUPLE_ELEM(4,3,MDLI),BOOST_PP_TUPLE_ELEM(3,0,BOOST_PP_TUPLE_ELEM(4,2,MDLI)))
#endif

View File

@ -13,18 +13,19 @@
* See http://www.boost.org for most recent version.
*/
#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>
<p><code>X</code> must be an integer literal in the range [0, BOOST_PP_LIMIT_MAG].</p>
<p>For example, <code>BOOST_PP_BOOL(3)</code> expands to <code>1</code>.</p>
*/
#define BOOST_PP_BOOL(X) BOOST_PP_BOOL_DELAY(X)
#define BOOST_PP_BOOL(X) BOOST_PP_DETAIL_CAT2(BOOST_PP_BOOL,X)
/* BOOL can be implemented in O(1) tokens using saturated ADD & SUB.
* Unfortunately, it would result in significantly slower preprocessing.
*/
#define BOOST_PP_BOOL_DELAY(X) BOOST_PP_BOOL##X
#define BOOST_PP_BOOL0 0
#define BOOST_PP_BOOL1 1
#define BOOST_PP_BOOL2 1

View File

@ -13,6 +13,7 @@
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/detail/cat.hpp>
#include <boost/preprocessor/logical/bool.hpp>
/** <p>Expands to the logical NEITHER OR of the operands.</p>
@ -27,12 +28,10 @@ in the range [0, BOOST_PP_LIMIT_MAG].</p>
<li><a href="../../test/logical_test.cpp">logical_test.cpp</a></li>
</ul>
*/
#define BOOST_PP_NOR(X,Y) BOOST_PP_NOR_BOOL(BOOST_PP_BOOL(X),BOOST_PP_BOOL(Y))
#define BOOST_PP_NOR(X,Y) BOOST_PP_DETAIL_CAT3(BOOST_PP_NOR,BOOST_PP_BOOL(X),BOOST_PP_BOOL(Y))
#define BOOST_PP_NOR_BOOL(X,Y) BOOST_PP_NOR_BOOL_DELAY(X,Y)
#define BOOST_PP_NOR_BOOL_DELAY(X,Y) BOOST_PP_NOR_BOOL##X##Y
#define BOOST_PP_NOR_BOOL00 1
#define BOOST_PP_NOR_BOOL01 0
#define BOOST_PP_NOR_BOOL10 0
#define BOOST_PP_NOR_BOOL11 0
#define BOOST_PP_NOR00 1
#define BOOST_PP_NOR01 0
#define BOOST_PP_NOR10 0
#define BOOST_PP_NOR11 0
#endif

View File

@ -13,6 +13,7 @@
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/detail/cat.hpp>
#include <boost/preprocessor/detail/auto_rec.hpp>
#include <boost/preprocessor/expand.hpp>
@ -90,8 +91,7 @@ are directly supported.</p>
#define BOOST_PP_REPEAT_AUTO_REC2(M,P) BOOST_PP_EXPAND(M P)
#define BOOST_PP_REPEAT_AUTO_REC3(M,P) BOOST_PP_EXPAND(M P)
#define BOOST_PP_REPEAT_1(C,M,D) BOOST_PP_REPEAT_AUTO_REC1(BOOST_PP_R1_DELAY(C),(M,D))
#define BOOST_PP_R1_DELAY(C) BOOST_PP_R1_##C
#define BOOST_PP_REPEAT_1(C,M,D) BOOST_PP_REPEAT_AUTO_REC1(BOOST_PP_DETAIL_CAT2(BOOST_PP_R1_,C),(M,D))
#define BOOST_PP_R1_0(M,D)
#define BOOST_PP_R1_1(M,D) M(0,D)
#define BOOST_PP_R1_2(M,D) M(0,D) M(1,D)
@ -222,8 +222,7 @@ are directly supported.</p>
#define BOOST_PP_R1_127(M,D) BOOST_PP_R1_126(M,D) M(126,D)
#define BOOST_PP_R1_128(M,D) BOOST_PP_R1_127(M,D) M(127,D)
#define BOOST_PP_REPEAT_2(C,M,D) BOOST_PP_REPEAT_AUTO_REC2(BOOST_PP_R2_DELAY(C),(M,D))
#define BOOST_PP_R2_DELAY(C) BOOST_PP_R2_##C
#define BOOST_PP_REPEAT_2(C,M,D) BOOST_PP_REPEAT_AUTO_REC2(BOOST_PP_DETAIL_CAT2(BOOST_PP_R2_,C),(M,D))
#define BOOST_PP_R2_0(M,D)
#define BOOST_PP_R2_1(M,D) M(0,D)
#define BOOST_PP_R2_2(M,D) M(0,D) M(1,D)
@ -354,8 +353,7 @@ are directly supported.</p>
#define BOOST_PP_R2_127(M,D) BOOST_PP_R2_126(M,D) M(126,D)
#define BOOST_PP_R2_128(M,D) BOOST_PP_R2_127(M,D) M(127,D)
#define BOOST_PP_REPEAT_3(C,M,D) BOOST_PP_REPEAT_AUTO_REC3(BOOST_PP_R3_DELAY(C),(M,D))
#define BOOST_PP_R3_DELAY(C) BOOST_PP_R3_##C
#define BOOST_PP_REPEAT_3(C,M,D) BOOST_PP_REPEAT_AUTO_REC3(BOOST_PP_DETAIL_CAT2(BOOST_PP_R3_,C),(M,D))
#define BOOST_PP_R3_0(M,D)
#define BOOST_PP_R3_1(M,D) M(0,D)
#define BOOST_PP_R3_2(M,D) M(0,D) M(1,D)

View File

@ -13,6 +13,8 @@
* See http://www.boost.org for most recent version.
*/
#include <boost/preprocessor/detail/cat.hpp>
/** <p>Expands to a macro that eats a tuple of the specified size.</p>
<p>BOOST_PP_TUPLE_EAT() is designed to be used with BOOST_PP_IF() like
@ -26,9 +28,8 @@ BOOST_PP_IF(0,BOOST_PP_ENUM_PARAMS,BOOST_PP_TUPLE_EAT(2))(10,P)
<p>expands to nothing.</p>
*/
#define BOOST_PP_TUPLE_EAT(SIZE_OF_TUPLE) BOOST_PP_TUPLE_EAT_DELAY(SIZE_OF_TUPLE)
#define BOOST_PP_TUPLE_EAT(SIZE_OF_TUPLE) BOOST_PP_DETAIL_CAT3(BOOST_PP_TUPLE,SIZE_OF_TUPLE,_EAT)
#define BOOST_PP_TUPLE_EAT_DELAY(N) BOOST_PP_TUPLE##N##_EAT
#define BOOST_PP_TUPLE0_EAT()
#define BOOST_PP_TUPLE1_EAT(A)
#define BOOST_PP_TUPLE2_EAT(A,B)