diff --git a/doc/acknowledgements.htm b/doc/acknowledgements.htm deleted file mode 100644 index 38c8977..0000000 --- a/doc/acknowledgements.htm +++ /dev/null @@ -1,43 +0,0 @@ - - - - -Boost.Preprocessor - Acknowledgements - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Acknowledgements

-
-
-

The original idea of passing two extra parameters to REPEAT, which makes it - possible to create preprocessor code on top of it, was due to Aleksey Gurtovoy. - The invokeable IDENTITY macro was also invented by him. He also suggested the - name for the library. Many thanks to Aleksey for his insights!

-

Thanks to everyone who participated in the review: David Abrahams, Beman Dawes, - Ronald Garcia, Douglas Gregor, Aleksey Gurtovoy, Jeremy Siek, and Daryle Walker.

-

Thanks to Chris Little and Mat Marcus for providing help with MWCW.

-

The original automatic recursion technique, which makes many of the library -primitives easier to use, was invented by Paul Mensonides.

-

The PREPROCESSOR library has been developed by Vesa Karvonen.

-
-

Revised - - -

-

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/bibliography.htm b/doc/bibliography.htm deleted file mode 100644 index 44082e5..0000000 --- a/doc/bibliography.htm +++ /dev/null @@ -1,48 +0,0 @@ - - - - -Boost.Preprocessor - Bibliography - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Bibliography

-
- -
- - - - - - - - - - - -
[Stroustrup]Stroustrup: The Design and Evolution of C++, ISBN 0201543303
[Czarnecki]Czarnecki, Eisenecker: Generative Programming, ISBN 0201309777
[Barton]Barton, Nackman: Scientific and Engineering C++, ISBN 0201533936
[McConnell]McConnell: Code Complete, ISBN 1556154844
[Std]ISO/IEC 14882:1998 Programming languages - C++
[Thompson]Thompson: Haskell: The Craft of Functional Programming, ISBN 0201342758
[Okasaki]Okasaki: Purely Functional Data Structures, ISBN 0521663504
[Cousineau]Cousineau, Mauny: The Functional Approach to Programming, ISBN 0521576814
[Abelson]Abelson, Sussman, Sussman: Structure and Interpretation of Computer Programs, ISBN 0262011530
- -
- -

Revised - - -

-

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/examples.htm b/doc/examples.htm deleted file mode 100644 index a4e93a7..0000000 --- a/doc/examples.htm +++ /dev/null @@ -1,91 +0,0 @@ - - - - -Boost.Preprocessor - Bibliography - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Examples

-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
array_arithmetic.cImplements over 2200 functions for 1-dimensional arithmetic -array manipulation in C. The idea is to use preprocessor data structures, -lists and tuples, for storing metainformation to be used for generating -the actual C code.
catch_builtin.cppDemonstrates the usage of lists and BOOST_PP_LIST_FOR_EACH().
count_down.c Trivial example of using BOOST_PP_WHILE() that simply counts - down from N to 0 ultimately expanding to a 0.
delay.cImplements a macro whose expansion takes exponential amount - of time.
duffs_device.cUses the preprocessor library to implement a generalized - macro for implementing a Duff's Device.
is_integral.cppDemonstrates the usage of preprocessor lists for generating - C++ code.
linear_fib.cShows how BOOST_PP_WHILE() can be used for implementing macros.
note.cShows how BOOST_PP_STRINGIZE() can be used to allow macro - expansion before stringization.
repeat_2d.cImplements a generalized macro for 2D repetition using the - simple repetition primitives of the preprocessor library.
static_assert.cShows how BOOST_PP_CAT() can be used to allow macro expansion - before token concatenation.
subscript_layer.cppShows how BOOST_PP_EMPTY can be used as an unused or empty - parameter.
- -
- -

Revised - - -

-

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/examples/array_arithmetic.c b/doc/examples/array_arithmetic.c new file mode 100644 index 0000000..91c6717 --- /dev/null +++ b/doc/examples/array_arithmetic.c @@ -0,0 +1,197 @@ +# /* Copyright (C) 2002 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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. +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# /* This example implements over 2200 functions for 1-dimensional arithmetic +# * array manipulation in C. The idea is to use preprocessor data structures, +# * lists, and tuples for storing metainformation to be used for generating +# * the actual C code. +# * +# * Who needs templates anyway? :) +# * +# * Compile with any C compiler with a standards conforming preprocessor. +# */ +# +# include +# include +# include +# include +# include +# include +# include +# include +# +# /* Information about C operators */ +# +# /* Accessors for the operator datatype. */ +# define OP_SYMBOL(O) BOOST_PP_TUPLE_ELEM(5, 0, O) +# define OP_NAME(O) BOOST_PP_TUPLE_ELEM(5, 1, O) +# define OP_IS_FLOATING(O) BOOST_PP_TUPLE_ELEM(5, 2, O) +# define OP_IS_LOGICAL(O) BOOST_PP_TUPLE_ELEM(5, 3, O) +# define OP_IS_SHIFT(O) BOOST_PP_TUPLE_ELEM(5, 4, O) +# +# /* List of applicative unary operators. */ +# define APPLICATIVE_UNARY_OPS \ + BOOST_PP_TUPLE_TO_LIST( \ + 3, \ + ( \ + ( ! , logical_not, 1, 1, 0), \ + ( ~ , bitwise_not, 0, 0, 0), \ + ( - , neg, 1, 0, 0) \ + ) \ + ) \ + /**/ +# +# /* List of applicative binary operators. */ +# define APPLICATIVE_BINARY_OPS \ + BOOST_PP_TUPLE_TO_LIST( \ + 18, \ + ( \ + ( * , mul ,1 ,0 ,0), \ + ( / , div ,1 ,0 ,0), \ + ( % , mod ,0 ,0 ,0), \ + ( + , add ,1 ,0 ,0), \ + ( - , sub ,1 ,0 ,0), \ + ( << , shift_left ,0 ,0 ,1), \ + ( >> , shift_right ,0 ,0 ,1), \ + ( < , less ,1 ,1 ,0), \ + ( <= , less_equal ,1 ,1 ,0), \ + ( >= , greater_equal ,1 ,1 ,0), \ + ( > , greater ,1 ,1 ,0), \ + ( == , equal ,1 ,1 ,0), \ + ( != , not_equal ,1 ,1 ,0), \ + ( & , bitwise_and ,0 ,0 ,0), \ + ( | , bitwise_or ,0 ,0 ,0), \ + ( ^ , bitwise_xor ,0 ,0 ,0), \ + ( && , logical_and ,1 ,1 ,0), \ + ( || , logical_or ,1 ,1 ,0) \ + ) \ + ) \ + /**/ +# +# /* Information about C built-in types. */ +# +# /* Accessors for the type datatype. */ +# define TYPE_NAME(T) BOOST_PP_TUPLE_ELEM(4, 0, T) +# define TYPE_ABBREVIATION(T) BOOST_PP_TUPLE_ELEM(4, 1, T) +# define TYPE_IS_FLOATING(T) BOOST_PP_TUPLE_ELEM(4, 2, T) +# define TYPE_RANK(T) BOOST_PP_TUPLE_ELEM(4, 3, T) +# +# /* List of C built-in types. */ +# define BUILTIN_TYPES \ + BOOST_PP_TUPLE_TO_LIST( \ + 12, \ + ( \ + ( signed char ,sc, 0, 1), \ + ( char ,ch, 0, 1), \ + ( unsigned char ,uc, 0, 1), \ + ( short ,ss, 0, 2), \ + ( unsigned short ,us, 0, 2), \ + TYPE_INT, \ + ( unsigned ,ui, 0, 4), \ + ( long ,sl, 0, 5), \ + ( unsigned long ,ul, 0, 6), \ + ( float ,fl, 1, 7), \ + ( double ,db, 1, 8), \ + ( long double ,ld, 1, 9) \ + ) \ + ) \ + /**/ +# +# /* Type int is needed in some type computations. */ +# define TYPE_INT (int, si, 0, 3) +# +# /* Type computation macros. */ +# define TYPE_OF_INTEGER_PROMOTION(T) \ + BOOST_PP_IF( \ + BOOST_PP_LESS(TYPE_RANK(T), TYPE_RANK(TYPE_INT)), \ + TYPE_INT, T \ + ) \ + /**/ +# define TYPE_OF_USUAL_ARITHMETIC_CONVERSION(L, R) \ + TYPE_OF_INTEGER_PROMOTION( \ + BOOST_PP_IF( \ + BOOST_PP_LESS(TYPE_RANK(L), TYPE_RANK(R)), \ + R, L \ + ) \ + ) \ + /**/ +# define TYPE_OF_UNARY_OP(O, T) \ + BOOST_PP_IF( \ + OP_IS_LOGICAL(O), \ + TYPE_INT, TYPE_OF_INTEGER_PROMOTION(T) \ + ) \ + /**/ +# define TYPE_OF_BINARY_OP(O, L, R) \ + BOOST_PP_IF( \ + OP_IS_LOGICAL(O), TYPE_INT, \ + BOOST_PP_IF( \ + OP_IS_SHIFT(O), \ + TYPE_OF_INTEGER_PROMOTION(L), \ + TYPE_OF_USUAL_ARITHMETIC_CONVERSION(L,R) \ + ) \ + ) \ + /**/ +# define IS_VALID_UNARY_OP_AND_TYPE_COMBINATION(O, T) \ + BOOST_PP_IF( \ + TYPE_IS_FLOATING(T), \ + OP_IS_FLOATING(O), 1 \ + ) \ + /**/ +# define IS_VALID_BINARY_OP_AND_TYPE_COMBINATION(O, L, R) \ + BOOST_PP_IF( \ + BOOST_PP_OR(TYPE_IS_FLOATING(L), TYPE_IS_FLOATING(R)), \ + OP_IS_FLOATING(O), 1 \ + ) \ + /**/ +# +# /* Generates code for all unary operators and integral types. */ +# define UNARY_ARRAY_OP(_, OT) \ + BOOST_PP_IF( \ + IS_VALID_UNARY_OP_AND_TYPE_COMBINATION OT, \ + UNARY_ARRAY_OP_CODE, BOOST_PP_TUPLE_EAT(2) \ + ) OT \ + /**/ +# define UNARY_ARRAY_OP_CODE(O, T) \ + void BOOST_PP_LIST_CAT(BOOST_PP_TUPLE_TO_LIST(4, (array_, OP_NAME(O), _, TYPE_ABBREVIATION(T)))) \ + (const TYPE_NAME(T)* in, TYPE_NAME(TYPE_OF_UNARY_OP(O, T))* out, unsigned n) { \ + do { \ + *out++ = OP_SYMBOL(O) *in++; \ + } while (--n); \ + } \ + /**/ + +BOOST_PP_LIST_FOR_EACH_PRODUCT(UNARY_ARRAY_OP, 2, (APPLICATIVE_UNARY_OPS, BUILTIN_TYPES)) + +# /* Generates code for all binary operators and integral type pairs. */ +# define BINARY_ARRAY_OP(_, OLR) \ + BOOST_PP_IF( \ + IS_VALID_BINARY_OP_AND_TYPE_COMBINATION OLR, \ + BINARY_ARRAY_OP_CODE, BOOST_PP_TUPLE_EAT(3) \ + ) OLR \ + /**/ +# define BINARY_ARRAY_OP_CODE(O, L, R) \ + void BOOST_PP_LIST_CAT( \ + BOOST_PP_TUPLE_TO_LIST( \ + 6, (array_, OP_NAME(O), _, TYPE_ABBREVIATION(L), _, TYPE_ABBREVIATION(R)) \ + ) \ + )(const TYPE_NAME(L)* lhs_in, const TYPE_NAME(R)* rhs_in, TYPE_NAME(TYPE_OF_BINARY_OP(O, L, R))* out, unsigned n) { \ + do { \ + *out++ = *lhs_in OP_SYMBOL(O) *rhs_in; \ + ++lhs_in; \ + ++rhs_in; \ + } while (--n); \ + } \ + /**/ + +BOOST_PP_LIST_FOR_EACH_PRODUCT(BINARY_ARRAY_OP, 3, (APPLICATIVE_BINARY_OPS, BUILTIN_TYPES, BUILTIN_TYPES)) diff --git a/doc/examples/catch_builtin.cpp b/doc/examples/catch_builtin.cpp new file mode 100644 index 0000000..7143699 --- /dev/null +++ b/doc/examples/catch_builtin.cpp @@ -0,0 +1,52 @@ +# /* Copyright (C) 2002 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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. +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# /* This example demonstrates the usage of lists and BOOST_PP_LIST_FOR_EACH(). */ +# +# include +# include +# +# include +# include +# +# /* List of built-in types. (Strictly speaking wchar_t should be on the list.) */ +# +# define BUILTIN_TYPES \ + BOOST_PP_TUPLE_TO_LIST( \ + 13, \ + ( \ + bool, \ + char, signed char, unsigned char, \ + unsigned short, short, \ + int, unsigned, \ + long, unsigned long, \ + float, \ + double, long double \ + ) \ + ) \ + /**/ +# +# define CATCH(R, _, T) \ + catch (T t) { \ + std::cerr << "Caught an " << typeid(t).name() << " = " << t; \ + } \ + /**/ + +int main() { + try { + throw 10; + } + BOOST_PP_LIST_FOR_EACH(CATCH, _, BUILTIN_TYPES) + return 0; +} diff --git a/doc/examples/delay.c b/doc/examples/delay.c new file mode 100644 index 0000000..54a9d40 --- /dev/null +++ b/doc/examples/delay.c @@ -0,0 +1,96 @@ +# /* Copyright (C) 2002 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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. +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# /* The time complexity of DELAY(N) is O(2^N). +# * +# * Handy when recompiles are too fast to take a coffee break. :) +# * +# * Template metaprogramming can be used for implementing similar +# * delays. Unfortunately template instantiation consumes memory, +# * therefore compilers usually fail to fully compile long template +# * based delays, because they run out of memory. +# * +# * On many compilers (e.g. g++, MSVC++), this macro takes only a +# * small amount of memory to preprocess. On some compilers (e.g. +# * MWCW), however, this macro seems to consume huge amounts of +# * memory. +# */ +# +# include +# include +# include +# include +# include +# +# ifndef DELAY_MAX +# define DELAY_MAX 14 +# endif +# +# define DELAY(N) BOOST_PP_TUPLE_ELEM(2, 0, (BOOST_PP_EMPTY, BOOST_PP_WHILE(DELAY_C, BOOST_PP_CAT(DELAY_F, N), BOOST_PP_DEC(N))))() +# +# define DELAY_C(D, N) N +# +# define DELAY_F0(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F1(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F2(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F3(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F4(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F5(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F6(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F7(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F8(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F9(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F10(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F11(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F12(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F13(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F14(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F15(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F16(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F17(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F18(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F19(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F20(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F21(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F22(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F23(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F24(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F25(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F26(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F27(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F28(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F29(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F30(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F31(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F32(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F33(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F34(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F35(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F36(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F37(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F38(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F39(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F40(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F41(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F42(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F43(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F44(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F45(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F46(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F47(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F48(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F49(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) +# define DELAY_F50(D, N) BOOST_PP_IF(1, BOOST_PP_DEC(N), BOOST_PP_WHILE_ ## D(DELAY_C, DELAY_F ## N, BOOST_PP_DEC(N))) + +DELAY(DELAY_MAX) diff --git a/doc/examples/duffs_device.c b/doc/examples/duffs_device.c new file mode 100644 index 0000000..a5e168f --- /dev/null +++ b/doc/examples/duffs_device.c @@ -0,0 +1,62 @@ +# /* Copyright (C) 2002 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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. +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# /* This example uses the preprocessor library to implement a generalized +# * macro for implementing Duff's Device. +# * +# * This example was inspired by an original generalized macro for +# * for implementing Duff's Device written by Joerg Walter. +# */ +# +# include +# +# include +# include +# +# /* Expands to a Duff's Device. */ +# define DUFFS_DEVICE(UNROLLING_FACTOR, COUNTER_TYPE, N, STATEMENT) \ + do { \ + COUNTER_TYPE duffs_device_initial_cnt = (N); \ + if (duffs_device_initial_cnt > 0) { \ + COUNTER_TYPE duffs_device_running_cnt = (duffs_device_initial_cnt + (UNROLLING_FACTOR - 1)) / UNROLLING_FACTOR; \ + switch (duffs_device_initial_cnt % UNROLLING_FACTOR) { \ + do { \ + BOOST_PP_REPEAT(UNROLLING_FACTOR, DUFFS_DEVICE_C, (UNROLLING_FACTOR, { STATEMENT })) \ + } while (--duffs_device_running_cnt); \ + } \ + } \ + } while (0) \ + /**/ +# +# define DUFFS_DEVICE_C(Z, I, UNROLLING_FACTOR_STATEMENT) \ + case (I ? BOOST_PP_TUPLE_ELEM(2, 0, UNROLLING_FACTOR_STATEMENT) - I : 0): \ + BOOST_PP_TUPLE_ELEM(2, 1, UNROLLING_FACTOR_STATEMENT); \ + /**/ +# +# ifndef UNROLLING_FACTOR +# define UNROLLING_FACTOR 16 +# endif +# +# ifndef N +# define N 1000 +# endif + +int main(void) { + int i = 0; + DUFFS_DEVICE(UNROLLING_FACTOR, int, 0, ++i;); + assert(i == 0); + DUFFS_DEVICE(UNROLLING_FACTOR, int, N, ++i;); + assert(i == N); + return 0; +} diff --git a/doc/examples/is_integral.cpp b/doc/examples/is_integral.cpp new file mode 100644 index 0000000..6a7f054 --- /dev/null +++ b/doc/examples/is_integral.cpp @@ -0,0 +1,50 @@ +# /* Copyright (C) 2002 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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. +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# /* This example demonstrates the usage of preprocessor lists for generating C++ code. */ +# +# include +# include +# include +# include +# include +# +# /* List of integral types. (Strictly speaking, wchar_t should be on the list.) */ +# define INTEGRAL_TYPES \ + BOOST_PP_TUPLE_TO_LIST( \ + 9, (char, signed char, unsigned char, short, unsigned short, int, unsigned, long, unsigned long) \ + ) \ + /**/ +# +# /* List of invokeable cv-qualifiers */ +# define CV_QUALIFIERS \ + BOOST_PP_TUPLE_TO_LIST( \ + 4, (BOOST_PP_EMPTY, const BOOST_PP_EMPTY, volatile BOOST_PP_EMPTY, const volatile BOOST_PP_EMPTY) \ + ) \ + /**/ +# +# /* Template for testing whether a type is an integral type. */ + +template struct is_integral { + enum { value = false }; +}; + +# /* Macro for defining a specialization of is_integral<> template. */ +# define IS_INTEGRAL_SPECIALIZATION(R, L) \ + template<> struct is_integral { \ + enum { value = true }; \ + }; \ + /**/ + +BOOST_PP_LIST_FOR_EACH_PRODUCT(IS_INTEGRAL_SPECIALIZATION, 2, (CV_QUALIFIERS, INTEGRAL_TYPES)) diff --git a/doc/examples/linear_fib.c b/doc/examples/linear_fib.c new file mode 100644 index 0000000..940e343 --- /dev/null +++ b/doc/examples/linear_fib.c @@ -0,0 +1,92 @@ +# /* Copyright (C) 2002 +# * Housemarque Oy +# * http://www.housemarque.com +# * +# * 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. +# */ +# +# /* Revised by Paul Mensonides (2002) */ +# +# /* See http://www.boost.org for most recent version. */ +# +# /* This example shows how BOOST_PP_WHILE() can be used for implementing macros. */ +# +# include +# +# include +# include +# include +# include +# include +# include +# +# /* First consider the following C implementation of Fibonacci. */ + +typedef struct linear_fib_state { + int a0, a1, n; +} linear_fib_state; + +static int linear_fib_c(linear_fib_state p) { + return p.n; +} + +static linear_fib_state linear_fib_f(linear_fib_state p) { + linear_fib_state r = { p.a1, p.a0 + p.a1, p.n - 1 }; + return r; +} + +static int linear_fib(int n) { + linear_fib_state p = { 0, 1, n }; + while (linear_fib_c(p)) { + p = linear_fib_f(p); + } + return p.a0; +} + +# /* Then consider the following preprocessor implementation of Fibonacci. */ +# +# define LINEAR_FIB(n) LINEAR_FIB_D(1, n) +# /* Since the macro is implemented using BOOST_PP_WHILE, the actual +# * implementation takes a depth as a parameters so that it can be called +# * inside a BOOST_PP_WHILE. The above easy-to-use version simply uses 1 +# * as the depth and cannot be called inside a BOOST_PP_WHILE. +# */ +# +# define LINEAR_FIB_D(d, n) \ + BOOST_PP_TUPLE_ELEM(3, 0, BOOST_PP_WHILE_ ## d(LINEAR_FIB_C, LINEAR_FIB_F, (0, 1, n))) +# /* ^^^^ ^^^^^ ^^ ^^ ^^^^^^^ +# * #1 #2 #3 #3 #4 +# * +# * 1) The state is a 3-element tuple. After the iteration is finished, the first +# * element of the tuple is the result. +# * +# * 2) The WHILE primitive is "invoked" directly. BOOST_PP_WHILE(D, ...) +# * can't be used because it would not be expanded by the preprocessor. +# * +# * 3) ???_C is the condition and ???_F is the iteration macro. +# */ +# +# define LINEAR_FIB_C(d, p) \ + /* p.n */ BOOST_PP_TUPLE_ELEM(3, 2, p) \ + /**/ +# +# define LINEAR_FIB_F(d, p) \ + ( \ + /* p.a1 */ BOOST_PP_TUPLE_ELEM(3, 1, p), \ + /* p.a0 + p.a1 */ BOOST_PP_ADD_D(d, BOOST_PP_TUPLE_ELEM(3, 0, p), BOOST_PP_TUPLE_ELEM(3, 1, p)), \ + /* ^^ ^ \ + * BOOST_PP_ADD() uses BOOST_PP_WHILE(). Therefore we \ + * pass the recursion depth explicitly to BOOST_PP_ADD_D(). \ + */ \ + /* p.n - 1 */ BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(3, 2, p)) \ + ) \ + /**/ + +int main() { + printf("linear_fib(10) = %d\n", linear_fib(10)); + printf("LINEAR_FIB(10) = %d\n", LINEAR_FIB(10)); + return 0; +} diff --git a/doc/examples/out.cpp b/doc/examples/out.cpp new file mode 100644 index 0000000..4fe5bc1 --- /dev/null +++ b/doc/examples/out.cpp @@ -0,0 +1,16 @@ + + +extern "C" { + + void _assert(const char*, const char*, unsigned); + +} + +int main(void) { + int i = 0; + do { int duffs_device_initial_cnt = (0); if (duffs_device_initial_cnt > 0) { int duffs_device_running_cnt = (duffs_device_initial_cnt + (16 - 1)) / 16; switch (duffs_device_initial_cnt % 16) { do { case (0 ? 16 - 0 : 0): { ++i; }; case (1 ? 16 - 1 : 0): { ++i; }; case (2 ? 16 - 2 : 0): { ++i; }; case (3 ? 16 - 3 : 0): { ++i; }; case (4 ? 16 - 4 : 0): { ++i; }; case (5 ? 16 - 5 : 0): { ++i; }; case (6 ? 16 - 6 : 0): { ++i; }; case (7 ? 16 - 7 : 0): { ++i; }; case (8 ? 16 - 8 : 0): { ++i; }; case (9 ? 16 - 9 : 0): { ++i; }; case (10 ? 16 - 10 : 0): { ++i; }; case (11 ? 16 - 11 : 0): { ++i; }; case (12 ? 16 - 12 : 0): { ++i; }; case (13 ? 16 - 13 : 0): { ++i; }; case (14 ? 16 - 14 : 0): { ++i; }; case (15 ? 16 - 15 : 0): { ++i; }; } while (--duffs_device_running_cnt); } } } while (0); + (void)( (i == 0) || (_assert("i == 0", "duffs_device.c", 58), 0) ); + do { int duffs_device_initial_cnt = (1000); if (duffs_device_initial_cnt > 0) { int duffs_device_running_cnt = (duffs_device_initial_cnt + (16 - 1)) / 16; switch (duffs_device_initial_cnt % 16) { do { case (0 ? 16 - 0 : 0): { ++i; }; case (1 ? 16 - 1 : 0): { ++i; }; case (2 ? 16 - 2 : 0): { ++i; }; case (3 ? 16 - 3 : 0): { ++i; }; case (4 ? 16 - 4 : 0): { ++i; }; case (5 ? 16 - 5 : 0): { ++i; }; case (6 ? 16 - 6 : 0): { ++i; }; case (7 ? 16 - 7 : 0): { ++i; }; case (8 ? 16 - 8 : 0): { ++i; }; case (9 ? 16 - 9 : 0): { ++i; }; case (10 ? 16 - 10 : 0): { ++i; }; case (11 ? 16 - 11 : 0): { ++i; }; case (12 ? 16 - 12 : 0): { ++i; }; case (13 ? 16 - 13 : 0): { ++i; }; case (14 ? 16 - 14 : 0): { ++i; }; case (15 ? 16 - 15 : 0): { ++i; }; } while (--duffs_device_running_cnt); } } } while (0); + (void)( (i == 1000) || (_assert("i == N", "duffs_device.c", 60), 0) ); + return 0; +} diff --git a/doc/examples_preprocessed.htm b/doc/examples_preprocessed.htm deleted file mode 100644 index 6f0deb7..0000000 --- a/doc/examples_preprocessed.htm +++ /dev/null @@ -1,326 +0,0 @@ - - - - -Boost.Preprocessor - Tutorial examples preprocessed - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Tutorial examples preprocessed

-
-
- -

The following code snippets were produced by actually preprocessing the code - snippets of the tutorial. After preprocessing the code was reformatted manually.

- -
-

EXAMPLE: - Use a Local Macro to avoid small scale repetition

- -
template<class T, int n>
-vec<T,n>&
-  operator +=
-  ( vec<T,n>&
-      lhs
-  , const vec<T,n>&
-      rhs
-  )
-{ for (int i=0; i<n; ++i)
-    lhs(i) += rhs(i);
-  return lhs;
-}
-
-template<class T, int n>
-vec<T,n>&
-  operator -=
-  ( vec<T,n>&
-      lhs
-  , const vec<T,n>&
-      rhs
-  )
-{ for (int i=0; i<n; ++i)
-    lhs(i) -= rhs(i);
-  return lhs;
-}
-
-template<class T, int n>
-vec<T,n>&
-  operator *=
-  ( vec<T,n>&
-      lhs
-  , const vec<T,n>&
-      rhs
-  )
-{ for (int i=0; i<n; ++i)
-    lhs(i) *= rhs(i);
-  return lhs;
-}
-
-template<class T, int n>
-vec<T,n>&
-  operator /=
-  ( vec<T,n>&
-      lhs
-  , const vec<T,n>&
-      rhs
-  )
-{ for (int i=0; i<n; ++i)
-    lhs(i) /= rhs(i);
-  return lhs;
-}
-
- -
-

EXAMPLE: - Use BOOST_PP_EMPTY() as an unused parameter in Local Macro instantiations

- -
template<class base>
-typename implement_subscript_using_begin_subscript<base>::value_type&
-  implement_subscript_using_begin_subscript<base>::operator[]
-  ( index_type
-      i
-  )
-{ return base::begin()[i];
-}
-
-template<class base>
-const typename implement_subscript_using_begin_subscript<base>::value_type&
-  implement_subscript_using_begin_subscript<base>::operator[]
-  ( index_type
-      i
-  ) const
-{ return base::begin()[i];
-}
-
- -
-

EXAMPLE: Use BOOST_PP_CAT instead of ## when necessary

- -
enum
-{ static_check_152 = (sizeof(int) <= sizeof(long)) ? 1 : -1
-};
-typedef char
-  static_assert_152
-  [ static_check_152
-  ];
-
-
-

EXAMPLE: Use BOOST_PP_STRINGIZE instead of # whenever necessary

-
#pragma message("examples.cpp" "(" "20" ") : " "TBD!")
-
-

EXAMPLE: - Use:

-
    -
  • BOOST_PP_ENUM_PARAMS,
  • -
  • BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT,
  • -
  • BOOST_PP_ENUM_PARAMS_WITH_DEFAULTS,
  • -
  • BOOST_PP_ENUM_SHIFTED_PARAMS, or
  • -
  • BOOST_PP_REPEAT, and
  • -
  • BOOST_PP_COMMA_IF
  • -
-

to avoid O(N) repetition on lists in general

-
struct make_type_list_end;
-
-template
-< class T0=make_type_list_end
-, class T1=make_type_list_end
-, class T2=make_type_list_end
-, class T3=make_type_list_end
-, class T4=make_type_list_end
-, class T5=make_type_list_end
-, class T6=make_type_list_end
-, class T7=make_type_list_end
->
-struct make_type_list
-{
-private:
-  enum
-  { end = is_same<T0,make_type_list_end>::value
-  };
-public:
-  typedef typename
-    type_if
-    < end
-    , type_cons_empty
-    , type_cons
-      < T0
-      , typename
-        type_inner_if
-        < end
-        , type_identity<end>
-        , make_type_list
-          < T1
-          , T2
-          , T3
-          , T4
-          , T5
-          , T6
-          , T7
-          >
-        >::type
-      >
-    >::type type;
-};
-
- -
-

EXAMPLE: - Use BOOST_PP_REPEAT and a Token Look-Up Function to eliminate categorical - repetition

- -
catch (bool t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (char t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (signed char t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (unsigned char t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (short t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (unsigned short t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (int t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (unsigned int t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (long t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (unsigned long t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (float t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (double t)
-{ report_typeid(t);
-  report_value(t);
-}
-catch (long double t)
-{ report_typeid(t);
-  report_value(t);
-}
-
- -
-

EXAMPLE: - Use BOOST_PP_REPEAT_2ND to avoid O(N*N) repetition

- -
vec()
-{
-}
-vec(T a0)
-{ (*this)[0] = a0;
-}
-vec(T a0, T a1)
-{ (*this)[0] = a0;
-  (*this)[1] = a1;
-}
-vec(T a0, T a1, T a2)
-{ (*this)[0] = a0;
-  (*this)[1] = a1;
-  (*this)[2] = a2;
-}
-vec(T a0, T a1, T a2, T a3)
-{ (*this)[0] = a0;
-  (*this)[1] = a1;
-  (*this)[2] = a2;
-  (*this)[3] = a3;
-}
-vec(T a0, T a1, T a2, T a3, T a4)
-{ (*this)[0] = a0;
-  (*this)[1] = a1;
-  (*this)[2] = a2;
-  (*this)[3] = a3;
-  (*this)[4] = a4;
-}
-vec(T a0, T a1, T a2, T a3, T a4, T a5)
-{ (*this)[0] = a0;
-  (*this)[1] = a1;
-  (*this)[2] = a2;
-  (*this)[3] = a3;
-  (*this)[4] = a4;
-  (*this)[5] = a5;
-}
-vec(T a0, T a1, T a2, T a3, T a4, T a5, T a6)
-{ (*this)[0] = a0;
-  (*this)[1] = a1;
-  (*this)[2] = a2;
-  (*this)[3] = a3;
-  (*this)[4] = a4;
-  (*this)[5] = a5;
-  (*this)[6] = a6;
-}
-vec(T a0, T a1, T a2, T a3, T a4, T a5, T a6, T a7)
-{ (*this)[0] = a0;
-  (*this)[1] = a1;
-  (*this)[2] = a2;
-  (*this)[3] = a3;
-  (*this)[4] = a4;
-  (*this)[5] = a5;
-  (*this)[6] = a6;
-  (*this)[7] = a7;
-}
-
- -

-


-

EXAMPLE: - Use BOOST_PP_IF to implement special case for the first element

- -
false == false;
-true == true;
-
- -

-


- -

EXAMPLE: Use arithmetic, logical and comparison operations when necessary

- -
S, E0, E1
-E0, S, E1
-E0, E1, S
-BAD PARAMS FOR SPECIAL_NUMBERED_LIST! E0, E1, E2, S
- -
-

Revised - - -

-

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/index.htm b/doc/index.htm deleted file mode 100644 index 41eb4e2..0000000 --- a/doc/index.htm +++ /dev/null @@ -1,48 +0,0 @@ - - - - -Boost.Preprocessor - Index - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Index

-
- -
- -

Contents

-
-
Tutorial
-
Examples
-
Reference
-
Widely known problems with the C preprocessor
-
Keywords for syntax highlighting
-
Known problems with specific compilers
-
Bibliography
-
Acknowledgements
-
- -
- -

Revised - -

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/keywords.txt b/doc/keywords.txt deleted file mode 100644 index 47568fd..0000000 --- a/doc/keywords.txt +++ /dev/null @@ -1,99 +0,0 @@ -BOOST_PP_ADD -BOOST_PP_ADD_D -BOOST_PP_AND -BOOST_PP_ASSERT_MSG -BOOST_PP_BOOL -BOOST_PP_CAT -BOOST_PP_COMMA -BOOST_PP_COMMA_IF -BOOST_PP_DEC -BOOST_PP_DIV -BOOST_PP_DIV_D -BOOST_PP_EMPTY -BOOST_PP_ENUM -BOOST_PP_ENUM_PARAMS -BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT -BOOST_PP_ENUM_PARAMS_WITH_DEFAULTS -BOOST_PP_ENUM_SHIFTED -BOOST_PP_ENUM_SHIFTED_PARAMS -BOOST_PP_EQUAL -BOOST_PP_EQUAL_D -BOOST_PP_EXPAND -BOOST_PP_EXPR_IF -BOOST_PP_FOR -BOOST_PP_GREATER -BOOST_PP_GREATER_D -BOOST_PP_GREATER_EQUAL -BOOST_PP_GREATER_EQUAL_D -BOOST_PP_IDENTITY -BOOST_PP_IF -BOOST_PP_INC -BOOST_PP_LESS -BOOST_PP_LESS_D -BOOST_PP_LESS_EQUAL -BOOST_PP_LESS_EQUAL_D -BOOST_PP_LIMIT_DIM -BOOST_PP_LIMIT_MAG -BOOST_PP_LIMIT_TUPLE -BOOST_PP_LIST_APPEND -BOOST_PP_LIST_APPEND_D -BOOST_PP_LIST_AT -BOOST_PP_LIST_AT_D -BOOST_PP_LIST_CAT -BOOST_PP_LIST_CAT_D -BOOST_PP_LIST_CONS -BOOST_PP_LIST_ENUM -BOOST_PP_LIST_ENUM_R -BOOST_PP_LIST_FILTER -BOOST_PP_LIST_FILTER_D -BOOST_PP_LIST_FIRST -BOOST_PP_LIST_FIRST_N -BOOST_PP_LIST_FIRST_N_D -BOOST_PP_LIST_FOLD_LEFT -BOOST_PP_LIST_FOLD_LEFT_D -BOOST_PP_LIST_FOLD_RIGHT -BOOST_PP_LIST_FOLD_RIGHT_D -BOOST_PP_LIST_FOR_EACH -BOOST_PP_LIST_FOR_EACH_I -BOOST_PP_LIST_FOR_EACH_I_R -BOOST_PP_LIST_FOR_EACH_R -BOOST_PP_LIST_FOR_EACH_PRODUCT -BOOST_PP_LIST_FOR_EACH_PRODUCT_R -BOOST_PP_LIST_IS_CONS -BOOST_PP_LIST_IS_NIL -BOOST_PP_LIST_NIL -BOOST_PP_LIST_REST -BOOST_PP_LIST_REST_N -BOOST_PP_LIST_REST_N_D -BOOST_PP_LIST_REVERSE -BOOST_PP_LIST_REVERSE_D -BOOST_PP_LIST_SIZE -BOOST_PP_LIST_SIZE_D -BOOST_PP_LIST_TO_TUPLE -BOOST_PP_LIST_TO_TUPLE_R -BOOST_PP_LIST_TRANSFORM -BOOST_PP_LIST_TRANSFORM_D -BOOST_PP_MAX -BOOST_PP_MAX_D -BOOST_PP_MIN -BOOST_PP_MIN_D -BOOST_PP_MOD -BOOST_PP_MOD_D -BOOST_PP_MUL -BOOST_PP_MUL_D -BOOST_PP_NOR -BOOST_PP_NOT -BOOST_PP_NOT_EQUAL -BOOST_PP_NOT_EQUAL_D -BOOST_PP_OR -BOOST_PP_REPEAT -BOOST_PP_REPEAT_FROM_TO -BOOST_PP_STRINGIZE -BOOST_PP_SUB -BOOST_PP_SUB_D -BOOST_PP_TUPLE_EAT -BOOST_PP_TUPLE_ELEM -BOOST_PP_TUPLE_REVERSE -BOOST_PP_TUPLE_TO_LIST -BOOST_PP_WHILE -BOOST_PP_XOR diff --git a/doc/known_problems_with_cpp.htm b/doc/known_problems_with_cpp.htm deleted file mode 100644 index c1d13e7..0000000 --- a/doc/known_problems_with_cpp.htm +++ /dev/null @@ -1,125 +0,0 @@ - - - - -Boost.Preprocessor - Widely known problems with the C preprocessor - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Widely known problems with the C preprocessor

-
- -
- -

Preprocessor metaprogramming is subject to heated discussions. Part of this is caused by -bad experiences with dangerous techniques, such as defining inline functions using macros. As a rule -of thumb, if you can find a clean and -manageable way to do something without using the preprocessor, then -you should do it that way.

- -

Let's survey some of the widely known problems with the preprocessor in a problem/solution - format.

-
- -

PROBLEM: Preprocessor does not -respect scope, therefore macros can accidentally and sometimes silently replace -code.

- -

SOLUTION A: Use all caps identifiers -for macros and only macros. This practically eliminates the possibility that a -macro might replace other kind of code accidentally.

- -

SOLUTION B: Use the Local Macro -idiom:

- -
#define MACRO ...
-// Use MACRO
-#undef MACRO
-
- -

This makes sure that a macro can not accidentally -replace code outside of the scope of the local macro.

-

A problem with this solution is that the #undef can not be automated and may be -forgotten. Experienced programmers generally write the #undef either immediately -before (in time) or immediately after writing the macro definition.

-

SOLUTION C: Use the Unique Macro Prefix idiom:

- -
#define UMP_MACRO
-// Use UMP_MACRO
-
- - -

This makes accidental substitution and collisions highly -unlikely. Problems with this solution:

-
    -
  • - There can still be naming collisions inside a large project. -
  • - Macros still pollute the global namespace.
-

By combining all solutions, whenever -possible, the scope problem can be largely avoided.

-
- -

PROBLEM:  Preprocessor code is difficult to read. -It requires understanding the basic process of how -the preprocessor recursively expands macros, finding the macro definition and mentally -substituting the parameters of the macro.

-

SOLUTION: Any kind of programming requires basic understanding - of how the code is executed. Any parameterization technique, including simple - functions and templates requires finding the definition and mentally substituting - parameters.

-

However, it is good to know a few techniques:

-
    -
  • - By using as many Local Macros as reasonable, the bulk of the searching - process can be eliminated. -
  • - Code browsers and text search tools make it easier to find the - definitions. -
  • - The compiler can be used for generating the preprocessed source code in - order to look for bugs. -
  • - Before turning something into a preprocessor metaprogram, first - implement a small scale version of it without preprocessor. Then work - bottom->up replacing hand written constructs by using preprocessor. This - way you can test the code incrementally. Experienced programmers often skip - many stages, but if something proves too complex to write directly, it is - always possible to fall back to incremental methods. -
  • - If you insert a special symbol into the preprocessor code in places where - there should be a line break, you can make code readable after preprocessing - simply by using a search and replace tool.
-

An especially important thing to remember is to limit the use of preprocessor - to the structured, well understood and safe methods. Structure helps to understand - complex systems [McConnell].

-
- -

PROBLEM: "I'd -like to see Cpp abolished." - Bjarne Stroustrup in [Stroustrup]

-

SOLUTION: The C preprocessor will be here for a -long time.

-

In practice, preprocessor metaprogramming is far simpler and more portable - than template metaprogramming [Czarnecki].

-
-

Revised - - -

-

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/problems_with_compilers.htm b/doc/problems_with_compilers.htm deleted file mode 100644 index 03bc664..0000000 --- a/doc/problems_with_compilers.htm +++ /dev/null @@ -1,138 +0,0 @@ - - - - -Boost.Preprocessor - Known problems with specific compilers - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Known problems with specific compilers

-
- -
- -

Some compilers have buggy or limited preprocessors. This page explains known - problems with specific compilers.

-
-

Contents

- -
- -

Metrowerks Codewarrior 7.0

-

Metrowerks Codewarrior 7.0 has a bug in preprocessor (to be more - concrete, in function-like macro replacement mechanism) that restricts usage - of the library to only very simple cases, at least if you don't write code that - specifically address this issue; for example, the above NUMBERED_EXPRESSION - example doesn't compile on CW 7.0. Below is a simple test case that reproduces - the bug:

- -
#define IDENTITY_MACRO(x) IDENTITY_MACRO_BODY(x)
-#define IDENTITY_MACRO_BODY(x) x
-#define COMMA_TOKEN() ,
-int a IDENTITY_MACRO(COMMA_TOKEN)() b; // this works
-int c IDENTITY_MACRO(IDENTITY_MACRO(COMMA_TOKEN))() d; // this doesn't
-
- -

Basically, what's happening here is that function-like COMMA_TOKEN macro gets - expanded _inside_ of the nested IDENTITY_MACRO call - even although it's NOT - followed by a '(' as the next preprocessing token - which is a clearly an incorrect - behavior (see 16.3 [cpp.replace] para 9 for the detailed description of the - function-like macro replacement process). I've submitted a bug report, but they - haven't confirmed it yet.

-

So, this is not a problem of the library, but probably something that needs - to be mentioned in the documentation, may be with some examples of how to workaround - the issue. Just to show one possible way around the problem, here is a NUMBERED_EXPRESSION - macro that does work on MWCW:

-
#define NUMBERED_EXPRESSION(n, x) \
-    BOOST_PP_CAT(BOOST_, \
-    BOOST_PP_IF( \
-      n \
-    , PREPROCESSOR_IDENTITY(x##n) \
-    , PREPROCESSOR_EMPTY \
-    ))() \
-/**/
-
-

Reported by Aleksey Gurtovoy

- -

Comeau C/C++ 4.2.45.2 for Windows

-

It appears that their algorithm of macro call invocation is quite far - from ideal, because for the following code fragment (which is a part of - preprocessor_test.cpp), the - linear increasing of IS_FUNCTION_HELPER_TEST_MAX value leads to not even - quadratic, but something like exponential increasing of compilation time! - (see the timing data below). This behavior may or may not be problematic - for you, depending on how intense is your usage of the library. - -

#ifndef IS_FUNCTION_HELPER_TEST_MAX
-#define IS_FUNCTION_HELPER_TEST_MAX 40
-#endif
-
-typedef char yes_type;
-
-#define IS_FUNCTION_HELPER(I,A)\
-  template\
-  <BOOST_PP_ENUM_PARAMS(BOOST_PP_INC(I),class P)>\
-  yes_type is_function_helper(\
-    P0 (*)(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_INC(I),P)));
-
-BOOST_PP_REPEAT_2ND(BOOST_PP_INC(IS_FUNCTION_HELPER_TEST_MAX),IS_FUNCTION_HELPER,A)
-
-#undef IS_FUNCTION_HELPER
-
- -

Timing data:

- - - - - - - - - - - - - - - - - - - - - - - - - - -
 Comeau C/C++ 4.2.45.2Microsoft Visual C++ 6.0 SP5
10 parameters< 1 sec< 1 sec
20 parameters~ 2 sec< 1 sec
30 parameters~ 15 sec< 1 sec
40 parameters~ 50 sec< 1 sec
- -

Reported by Aleksey Gurtovoy

- -
-

Revised - - -

-

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/arithmetic.htm b/doc/reference/arithmetic.htm deleted file mode 100644 index 448f451..0000000 --- a/doc/reference/arithmetic.htm +++ /dev/null @@ -1,41 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/arithmetic.hpp>

-
- -
- -Prev Next Macros Headers -
- -

Includes all arithmetic headers.

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/arithmetic_add.htm b/doc/reference/arithmetic_add.htm deleted file mode 100644 index 126a817..0000000 --- a/doc/reference/arithmetic_add.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/arithmetic/add.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_ADD(X,Y)

-

Expands to the sum of X and Y.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_ADD(4,3) expands to 7 (a -single token).

- -

Test

- - -
- -

#define BOOST_PP_ADD_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/arithmetic_div.htm b/doc/reference/arithmetic_div.htm deleted file mode 100644 index 120eba5..0000000 --- a/doc/reference/arithmetic_div.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/arithmetic/div.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_DIV(X,Y)

-

Expands to the quotient of X and Y.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_DIV(4,3) expands to 1 (a -single token).

- -

Test

- - -
- -

#define BOOST_PP_DIV_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/arithmetic_mod.htm b/doc/reference/arithmetic_mod.htm deleted file mode 100644 index 68c6a3a..0000000 --- a/doc/reference/arithmetic_mod.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/arithmetic/mod.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_MOD(X,Y)

-

Expands to the remainder of X and Y.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_MOD(4,3) expands to 1 (a -single token).

- -

Test

- - -
- -

#define BOOST_PP_MOD_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/arithmetic_mul.htm b/doc/reference/arithmetic_mul.htm deleted file mode 100644 index 4799c0d..0000000 --- a/doc/reference/arithmetic_mul.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/arithmetic/mul.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_MUL(X,Y)

-

Expands to the product of X and Y.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_MUL(4,3) expands to 12 (a -single token).

- -

Test

- - -
- -

#define BOOST_PP_MUL_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/arithmetic_sub.htm b/doc/reference/arithmetic_sub.htm deleted file mode 100644 index 9ff9b41..0000000 --- a/doc/reference/arithmetic_sub.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/arithmetic/sub.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_SUB(X,Y)

-

Expands to the difference of X and Y.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_SUB(4,3) expands to 1 (a -single token).

- -

Test

- - -
- -

#define BOOST_PP_SUB_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/assert_msg.htm b/doc/reference/assert_msg.htm deleted file mode 100644 index 4eade5f..0000000 --- a/doc/reference/assert_msg.htm +++ /dev/null @@ -1,49 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/assert_msg.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_ASSERT_MSG(COND,MSG)

-

Expands to nothing if COND != 0 and to MSG if -COND == 0.

- -

COND must expand to an integer literal in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_ASSERT_MSG(1,A BUG!) expands to A BUG!.

- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/cat.htm b/doc/reference/cat.htm deleted file mode 100644 index 65c794c..0000000 --- a/doc/reference/cat.htm +++ /dev/null @@ -1,57 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/cat.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_CAT(X,Y)

-

Concatenates X and Y after they are macro -expanded.

- -

For example, BOOST_PP_CAT(A,BOOST_PP_CAT(_,B)) expands to A_B.

- -

Example

- - -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/comma.htm b/doc/reference/comma.htm deleted file mode 100644 index 305d98d..0000000 --- a/doc/reference/comma.htm +++ /dev/null @@ -1,60 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/comma.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_COMMA()

-

Expands to a comma.

- -

Commas need special handling in preprocessor code, because commas are used -for separating macro parameters.

- -

For example,

- -
-BOOST_PP_IF(1,BOOST_PP_COMMA,BOOST_PP_EMPTY)()
-
- -

expands to a comma.

- -

See

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/comma_if.htm b/doc/reference/comma_if.htm deleted file mode 100644 index 4f6e587..0000000 --- a/doc/reference/comma_if.htm +++ /dev/null @@ -1,49 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/comma_if.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_COMMA_IF(COND)

-

Expands to a comma if COND != 0 and nothing if -COND == 0.

- -

COND must expand to an integer literal in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_COMMA_IF(0) expands to nothing.

- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/comparison.htm b/doc/reference/comparison.htm deleted file mode 100644 index 6978b7b..0000000 --- a/doc/reference/comparison.htm +++ /dev/null @@ -1,41 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/comparison.hpp>

-
- -
- -Prev Next Macros Headers -
- -

Includes all comparison headers.

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/comparison_equal.htm b/doc/reference/comparison_equal.htm deleted file mode 100644 index abb12c1..0000000 --- a/doc/reference/comparison_equal.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/comparison/equal.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_EQUAL(X,Y)

-

Expands to 1 if X == Y and 0 -otherwise.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_EQUAL(4,4) expands to 1.

- -

Test

- - -
- -

#define BOOST_PP_EQUAL_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/comparison_greater.htm b/doc/reference/comparison_greater.htm deleted file mode 100644 index 7cfa4c2..0000000 --- a/doc/reference/comparison_greater.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/comparison/greater.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_GREATER(X,Y)

-

Expands to 1 if X > Y and 0 -otherwise.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_GREATER(4,3) expands to 1.

- -

Test

- - -
- -

#define BOOST_PP_GREATER_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/comparison_greater_equal.htm b/doc/reference/comparison_greater_equal.htm deleted file mode 100644 index 084d356..0000000 --- a/doc/reference/comparison_greater_equal.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/comparison/greater_equal.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_GREATER_EQUAL(X,Y)

-

Expands to 1 if X >= Y and 0 -otherwise.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_GREATER_EQUAL(1,3) expands to 0.

- -

Test

- - -
- -

#define BOOST_PP_GREATER_EQUAL_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/comparison_less.htm b/doc/reference/comparison_less.htm deleted file mode 100644 index fab9f37..0000000 --- a/doc/reference/comparison_less.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/comparison/less.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LESS(X,Y)

-

Expands to 1 if X < Y and 0 -otherwise.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_LESS(2,6) expands to 1.

- -

Test

- - -
- -

#define BOOST_PP_LESS_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/comparison_less_equal.htm b/doc/reference/comparison_less_equal.htm deleted file mode 100644 index 6267779..0000000 --- a/doc/reference/comparison_less_equal.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/comparison/less_equal.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LESS_EQUAL(X,Y)

-

Expands to 1 if X <= Y and 0 -otherwise.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_LESS_EQUAL(7,5) expands to 0.

- -

Test

- - -
- -

#define BOOST_PP_LESS_EQUAL_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/comparison_not_equal.htm b/doc/reference/comparison_not_equal.htm deleted file mode 100644 index 3ab7d6b..0000000 --- a/doc/reference/comparison_not_equal.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/comparison/not_equal.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_NOT_EQUAL(X,Y)

-

Expands to 1 if X != Y and 0 -otherwise.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_NOT_EQUAL(4,4) expands to 0.

- -

Test

- - -
- -

#define BOOST_PP_NOT_EQUAL_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/dec.htm b/doc/reference/dec.htm deleted file mode 100644 index d8e309a..0000000 --- a/doc/reference/dec.htm +++ /dev/null @@ -1,52 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/dec.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_DEC(X)

-

Decrements X expanding to a single token.

- -

For example, BOOST_PP_DEC(3) expands to 2 (a -single token).

- -

BOOST_PP_DEC() uses saturation arithmetic. Decrementing 0 yeilds a 0.

- -

Only decimal integer literals in the range [0,BOOST_PP_LIMIT_MAG] are -supported.

- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/empty.htm b/doc/reference/empty.htm deleted file mode 100644 index fc14256..0000000 --- a/doc/reference/empty.htm +++ /dev/null @@ -1,62 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/empty.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_EMPTY()

-

Expands to nothing.

- -

For example,

- -
-BOOST_PP_IF(0,BOOST_PP_COMMA,BOOST_PP_EMPTY)()
-
- -

expands to nothing.

- -

Example

- - -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/enum.htm b/doc/reference/enum.htm deleted file mode 100644 index e89bcb6..0000000 --- a/doc/reference/enum.htm +++ /dev/null @@ -1,81 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/enum.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_ENUM(COUNT,MACRO,DATA)

-

Generates a comma separated list.

- -

In other words, expands to the sequence:

- -
-MACRO(0,DATA), MACRO(1,DATA), ..., MACRO(BOOST_PP_DEC(COUNT),DATA)
-
- -

For example,

- -
-#define TYPED_PARAM(INDEX,DATA)\
-  BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2,0,DATA),INDEX) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2,1,DATA),INDEX)
-BOOST_PP_ENUM(3,TYPED_PARAM,(X,x))
-
- -

expands to:

- -
-X0 x0, X1 x1, X2 x2
-
- -

2D and 3D repetition

- -

BOOST_PP_ENUM() implements automatic recursion. 2D and 3D repetition -are directly supported.

- -

See

- - -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/enum_params.htm b/doc/reference/enum_params.htm deleted file mode 100644 index a257eba..0000000 --- a/doc/reference/enum_params.htm +++ /dev/null @@ -1,72 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/enum_params.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_ENUM_PARAMS(COUNT,PARAM)

-

Generates a comma separated list of parameters.

- -

In other words, expands to the sequence:

- -
-BOOST_PP_CAT(PARAM,0), BOOST_PP_CAT(PARAM,1), ..., BOOST_PP_CAT(PARAM,BOOST_PP_DEC(COUNT))
-
- -

For example,

- -
-BOOST_PP_ENUM_PARAMS(3,x)
-
- -

expands to:

- -
-x0, x1, x2
-
- -

Uses

- - -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/enum_params_with_a_default.htm b/doc/reference/enum_params_with_a_default.htm deleted file mode 100644 index 8d10a14..0000000 --- a/doc/reference/enum_params_with_a_default.htm +++ /dev/null @@ -1,75 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/enum_params_with_a_default.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(COUNT,PARAM,DEFAULT)

-

Generates a comma separated list of parameters with a default.

- -

In other words, expands to the sequence:

- -
-BOOST_PP_CAT(PARAM,0) = DEFAULT,
-BOOST_PP_CAT(PARAM,1) = DEFAULT,
-...,
-BOOST_PP_CAT(PARAM,BOOST_PP_DEC(COUNT)) = DEFAULT
-
- -

For example,

- -
-BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(3,x,y)
-
- -

expands to:

- -
-x0 = y, x1 = y, x2 = y
-
- -

Uses

- - -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/enum_params_with_defaults.htm b/doc/reference/enum_params_with_defaults.htm deleted file mode 100644 index a635190..0000000 --- a/doc/reference/enum_params_with_defaults.htm +++ /dev/null @@ -1,75 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/enum_params_with_defaults.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_ENUM_PARAMS_WITH_DEFAULTS(COUNT,PARAM,DEFAULT)

-

Generates a comma separated list of parameters with defaults.

- -

In other words, expands to the sequence:

- -
-BOOST_PP_CAT(PARAM,0) = BOOST_PP_CAT(DEFAULT,0),
-BOOST_PP_CAT(PARAM,1) = BOOST_PP_CAT(DEFAULT,1),
-...,
-BOOST_PP_CAT(PARAM,BOOST_PP_DEC(COUNT)) = BOOST_PP_CAT(DEFAULT,BOOST_PP_DEC(COUNT))
-
- -

For example,

- -
-BOOST_PP_ENUM_PARAMS_WITH_DEFAULTS(3,x,y)
-
- -

expands to:

- -
-x0 = y0, x1 = y1, x2 = y2
-
- -

Uses

- - -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/enum_shifted.htm b/doc/reference/enum_shifted.htm deleted file mode 100644 index 61b51a0..0000000 --- a/doc/reference/enum_shifted.htm +++ /dev/null @@ -1,69 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/enum_shifted.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_ENUM_SHIFTED(COUNT,MACRO,DATA)

-

Generates a comma separated shifted list.

- -

In other words, expands to the sequence:

- -
-MACRO(1,DATA), MACRO(2,DATA), ..., MACRO(BOOST_PP_DEC(COUNT),DATA)
-
- -

For example,

- -
-#define TYPED_PARAM(INDEX,DATA)\
-  BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2,0,DATA),INDEX) BOOST_PP_CAT(BOOST_PP_TUPLE_ELEM(2,1,DATA),INDEX)
-BOOST_PP_ENUM_SHIFTED(3,TYPED_PARAM,(X,x))
-
- -

expands to:

- -
-X1 x1, X2 x2
-
- -

Uses

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/enum_shifted_params.htm b/doc/reference/enum_shifted_params.htm deleted file mode 100644 index 33679ff..0000000 --- a/doc/reference/enum_shifted_params.htm +++ /dev/null @@ -1,77 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/enum_shifted_params.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_ENUM_SHIFTED_PARAMS(COUNT,PARAM)

-

Generates a comma separated list of shifted actual parameters.

- -

In other words, expands to the sequence:

- -
-BOOST_PP_CAT(PARAM,1), BOOST_PP_CAT(PARAM,2), ..., BOOST_PP_CAT(PARAM,BOOST_PP_DEC(COUNT))
-
-

For example,

- -
-BOOST_PP_ENUM_SHIFTED_PARAMS(3,x)
-
- -

expands to:

- -
-x1, x2
-
- -

Uses

- - -

Rationale

-
    -
  • This macro facilitates a typical usage of the library. Shifted parameter - lists are common in template metaprograms.
  • -
- -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/expand.htm b/doc/reference/expand.htm deleted file mode 100644 index 306f2da..0000000 --- a/doc/reference/expand.htm +++ /dev/null @@ -1,43 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/expand.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_EXPAND(X)

-

Essentially macro expands the parameter X twice.

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/expr_if.htm b/doc/reference/expr_if.htm deleted file mode 100644 index 541f234..0000000 --- a/doc/reference/expr_if.htm +++ /dev/null @@ -1,53 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/expr_if.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_EXPR_IF(COND,EXPR)

-

Expands to EXPR if COND != 0 and to nothing if COND == 0.

- -

COND must expand to an integer literal in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_EXPR_IF(1,^) expands to ^.

- -

See

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/for.htm b/doc/reference/for.htm deleted file mode 100644 index 84bd48d..0000000 --- a/doc/reference/for.htm +++ /dev/null @@ -1,114 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/for.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_FOR(STATE,PRED,OP,MACRO)

-

Repeats MACRO(R,STATE) and iterates OP(R,STATE) while -PRED(R,STATE) is true.

- -

In other words, expands to the sequence:

- -
-MACRO(R,STATE)
-MACRO(R,OP(R,STATE))
-MACRO(R,OP(R,OP(R,STATE)))
-...
-MACRO(R,OP(R,OP(...OP(R,STATE)...)))
-
- -

The length of the sequence is determined by PRED(R,STATE).

- -

For example,

- -
-#define PRED(R,STATE) BOOST_PP_LESS(BOOST_PP_TUPLE_ELEM(2,0,STATE),BOOST_PP_TUPLE_ELEM(2,1,STATE))
-#define OP(R,STATE) (BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(2,0,STATE)),BOOST_PP_TUPLE_ELEM(2,1,STATE))
-#define MACRO(R,STATE) BOOST_PP_TUPLE_ELEM(2,0,STATE)
-BOOST_PP_FOR((0,3),PRED,OP,MACRO)
-
- -

expands to:

- -
-0 1 2
-
- -

Legend

-
    -
  • STATE is the current state of iteration. The state is usually a tuple.
  • -
  • PRED is the condition for iteration. It must expand to a decimal - integer literal.
  • -
  • OP is the iterated macro. Note that if the state is a tuple, then - OP(R,STATE) usually expands to a tuple of the same number of elements.
  • -
  • MACRO is the state instantiation macro.
  • -
  • R is the recursion depth and should only be used as a parameter to - other macros using BOOST_PP_FOR() or for invoking BOOST_PP_FOR##R() - directly. For each macro using BOOST_PP_FOR(), e.g. BOOST_PP_LIST_FOR_EACH(), - there is a version of the macro, e.g. BOOST_PP_LIST_FOR_EACH_R(), distinguished - by the R suffix, that accepts an additional recursion depth as the first - parameter. This technique is necessary to avoid recursively expanding the same - macro again, which is not permitted by the C++ preprocessor.
  • -
- -

BOOST_PP_REPEAT() vs BOOST_PP_FOR()

- -

BOOST_PP_FOR() is a generalization of BOOST_PP_REPEAT(). This means that -BOOST_PP_REPEAT() can be implemented using BOOST_PP_FOR(). However, -BOOST_PP_REPEAT() was introduced earlier, is generally easier to use, and is -still quite useful on its own.

- -

2D and 3D repetition

- -

BOOST_PP_FOR() can be used for multidimensional repetition simply by -invoking BOOST_PP_FOR##R() directly.

- -

Automatic recursion?

- -

BOOST_PP_FOR() currently does not implement automatic recursion. The reason -for this is that it would lead to very poor performance. The automatic recursion -technique takes O(N) steps just to find out that the Nth recursion should be used. -This would dramatically effect the time complexity of macros using automatic -recursion.

- -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/identity.htm b/doc/reference/identity.htm deleted file mode 100644 index 32a28a0..0000000 --- a/doc/reference/identity.htm +++ /dev/null @@ -1,64 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/identity.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_IDENTITY(X)

-

Expands to X once invoked.

- -

Designed to be used with BOOST_PP_IF(), when one of the clauses need to be -invoked.

- -

For example,

- -
-BOOST_PP_IF(1,BOOST_PP_IDENTITY(X),BOOST_PP_EMPTY)()
-
- -

expands to:

- -
-X
-
- -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/if.htm b/doc/reference/if.htm deleted file mode 100644 index b2ceb31..0000000 --- a/doc/reference/if.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/if.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_IF(COND,THEN,ELSE)

-

Expands to THEN if COND != 0 and ELSE if -COND == 0.

- -

COND must expand to an integer literal in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_IF(0,1,2) expands to 2.

- -

See

- - -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/inc.htm b/doc/reference/inc.htm deleted file mode 100644 index 90b2e4b..0000000 --- a/doc/reference/inc.htm +++ /dev/null @@ -1,53 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/inc.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_INC(X)

-

Increments X expanding to a single token.

- -

For example, BOOST_PP_INC(3) expands to 4 (a -single token).

- -

BOOST_PP_INC() uses saturation arithmetic. Incrementing a -BOOST_PP_LIMIT_MAG yields a BOOST_PP_LIMIT_MAG.

- -

Only decimal integer literals in the range [0,BOOST_PP_LIMIT_MAG] are -supported.

- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/index.htm b/doc/reference/index.htm deleted file mode 100644 index 599ae7e..0000000 --- a/doc/reference/index.htm +++ /dev/null @@ -1,225 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Reference

-
-
- -

Macros (Headers)

- -
-
BOOST_PP_ADD
-
BOOST_PP_ADD_D
-
BOOST_PP_AND
-
BOOST_PP_ASSERT_MSG
-
BOOST_PP_BOOL
-
BOOST_PP_CAT
-
BOOST_PP_COMMA
-
BOOST_PP_COMMA_IF
-
BOOST_PP_DEC
-
BOOST_PP_DIV
-
BOOST_PP_DIV_D
-
BOOST_PP_EMPTY
-
BOOST_PP_ENUM
-
BOOST_PP_ENUM_PARAMS
-
BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT
-
BOOST_PP_ENUM_PARAMS_WITH_DEFAULTS
-
BOOST_PP_ENUM_SHIFTED
-
BOOST_PP_ENUM_SHIFTED_PARAMS
-
BOOST_PP_EQUAL
-
BOOST_PP_EQUAL_D
-
BOOST_PP_EXPAND
-
BOOST_PP_EXPR_IF
-
BOOST_PP_FOR
-
BOOST_PP_GREATER
-
BOOST_PP_GREATER_D
-
BOOST_PP_GREATER_EQUAL
-
BOOST_PP_GREATER_EQUAL_D
-
BOOST_PP_IDENTITY
-
BOOST_PP_IF
-
BOOST_PP_INC
-
BOOST_PP_LESS
-
BOOST_PP_LESS_D
-
BOOST_PP_LESS_EQUAL
-
BOOST_PP_LESS_EQUAL_D
-
BOOST_PP_LIMIT_DIM
-
BOOST_PP_LIMIT_MAG
-
BOOST_PP_LIMIT_TUPLE
-
BOOST_PP_LIST_APPEND
-
BOOST_PP_LIST_APPEND_D
-
BOOST_PP_LIST_AT
-
BOOST_PP_LIST_AT_D
-
BOOST_PP_LIST_CAT
-
BOOST_PP_LIST_CAT_D
-
BOOST_PP_LIST_CONS
-
BOOST_PP_LIST_ENUM
-
BOOST_PP_LIST_ENUM_R
-
BOOST_PP_LIST_FILTER
-
BOOST_PP_LIST_FILTER_D
-
BOOST_PP_LIST_FIRST
-
BOOST_PP_LIST_FIRST_N
-
BOOST_PP_LIST_FIRST_N_D
-
BOOST_PP_LIST_FOLD_LEFT
-
BOOST_PP_LIST_FOLD_LEFT_2ND
-
BOOST_PP_LIST_FOLD_LEFT_2ND_D
-
BOOST_PP_LIST_FOLD_LEFT_D
-
BOOST_PP_LIST_FOLD_RIGHT
-
BOOST_PP_LIST_FOLD_RIGHT_2ND
-
BOOST_PP_LIST_FOLD_RIGHT_2ND_D
-
BOOST_PP_LIST_FOLD_RIGHT_D
-
BOOST_PP_LIST_FOR_EACH
-
BOOST_PP_LIST_FOR_EACH_I
-
BOOST_PP_LIST_FOR_EACH_I_R
-
BOOST_PP_LIST_FOR_EACH_PRODUCT
-
BOOST_PP_LIST_FOR_EACH_PRODUCT_R
-
BOOST_PP_LIST_FOR_EACH_R
-
BOOST_PP_LIST_IS_CONS
-
BOOST_PP_LIST_IS_NIL
-
BOOST_PP_LIST_NIL
-
BOOST_PP_LIST_REST
-
BOOST_PP_LIST_REST_N
-
BOOST_PP_LIST_REST_N_D
-
BOOST_PP_LIST_REVERSE
-
BOOST_PP_LIST_REVERSE_D
-
BOOST_PP_LIST_SIZE
-
BOOST_PP_LIST_SIZE_D
-
BOOST_PP_LIST_TO_TUPLE
-
BOOST_PP_LIST_TO_TUPLE_R
-
BOOST_PP_LIST_TRANSFORM
-
BOOST_PP_LIST_TRANSFORM_D
-
BOOST_PP_MAX
-
BOOST_PP_MAX_D
-
BOOST_PP_MIN
-
BOOST_PP_MIN_D
-
BOOST_PP_MOD
-
BOOST_PP_MOD_D
-
BOOST_PP_MUL
-
BOOST_PP_MUL_D
-
BOOST_PP_NOR
-
BOOST_PP_NOT
-
BOOST_PP_NOT_EQUAL
-
BOOST_PP_NOT_EQUAL_D
-
BOOST_PP_OR
-
BOOST_PP_REPEAT
-
BOOST_PP_REPEAT_2ND
-
BOOST_PP_REPEAT_3RD
-
BOOST_PP_REPEAT_FROM_TO
-
BOOST_PP_REPEAT_FROM_TO_2ND
-
BOOST_PP_REPEAT_FROM_TO_3RD
-
BOOST_PP_STRINGIZE
-
BOOST_PP_SUB
-
BOOST_PP_SUB_D
-
BOOST_PP_TUPLE_EAT
-
BOOST_PP_TUPLE_ELEM
-
BOOST_PP_TUPLE_REVERSE
-
BOOST_PP_TUPLE_TO_LIST
-
BOOST_PP_WHILE
-
BOOST_PP_XOR
-
-
- -

Headers (Macros)

- -
-
#include <boost/preprocessor/arithmetic.hpp>
-
#include <boost/preprocessor/arithmetic/add.hpp>
-
#include <boost/preprocessor/arithmetic/div.hpp>
-
#include <boost/preprocessor/arithmetic/mod.hpp>
-
#include <boost/preprocessor/arithmetic/mul.hpp>
-
#include <boost/preprocessor/arithmetic/sub.hpp>
-
#include <boost/preprocessor/assert_msg.hpp>
-
#include <boost/preprocessor/cat.hpp>
-
#include <boost/preprocessor/comma.hpp>
-
#include <boost/preprocessor/comma_if.hpp>
-
#include <boost/preprocessor/comparison.hpp>
-
#include <boost/preprocessor/comparison/equal.hpp>
-
#include <boost/preprocessor/comparison/greater.hpp>
-
#include <boost/preprocessor/comparison/greater_equal.hpp>
-
#include <boost/preprocessor/comparison/less.hpp>
-
#include <boost/preprocessor/comparison/less_equal.hpp>
-
#include <boost/preprocessor/comparison/not_equal.hpp>
-
#include <boost/preprocessor/dec.hpp>
-
#include <boost/preprocessor/empty.hpp>
-
#include <boost/preprocessor/enum.hpp>
-
#include <boost/preprocessor/enum_params.hpp>
-
#include <boost/preprocessor/enum_params_with_a_default.hpp>
-
#include <boost/preprocessor/enum_params_with_defaults.hpp>
-
#include <boost/preprocessor/enum_shifted.hpp>
-
#include <boost/preprocessor/enum_shifted_params.hpp>
-
#include <boost/preprocessor/expand.hpp>
-
#include <boost/preprocessor/expr_if.hpp>
-
#include <boost/preprocessor/for.hpp>
-
#include <boost/preprocessor/identity.hpp>
-
#include <boost/preprocessor/if.hpp>
-
#include <boost/preprocessor/inc.hpp>
-
#include <boost/preprocessor/limits.hpp>
-
#include <boost/preprocessor/list.hpp>
-
#include <boost/preprocessor/list/adt.hpp>
-
#include <boost/preprocessor/list/append.hpp>
-
#include <boost/preprocessor/list/at.hpp>
-
#include <boost/preprocessor/list/cat.hpp>
-
#include <boost/preprocessor/list/enum.hpp>
-
#include <boost/preprocessor/list/filter.hpp>
-
#include <boost/preprocessor/list/first_n.hpp>
-
#include <boost/preprocessor/list/fold_left.hpp>
-
#include <boost/preprocessor/list/fold_left_2nd.hpp>
-
#include <boost/preprocessor/list/fold_right.hpp>
-
#include <boost/preprocessor/list/fold_right_2nd.hpp>
-
#include <boost/preprocessor/list/for_each.hpp>
-
#include <boost/preprocessor/list/for_each_i.hpp>
-
#include <boost/preprocessor/list/for_each_product.hpp>
-
#include <boost/preprocessor/list/rest_n.hpp>
-
#include <boost/preprocessor/list/reverse.hpp>
-
#include <boost/preprocessor/list/size.hpp>
-
#include <boost/preprocessor/list/to_tuple.hpp>
-
#include <boost/preprocessor/list/transform.hpp>
-
#include <boost/preprocessor/logical.hpp>
-
#include <boost/preprocessor/logical/and.hpp>
-
#include <boost/preprocessor/logical/bool.hpp>
-
#include <boost/preprocessor/logical/nor.hpp>
-
#include <boost/preprocessor/logical/not.hpp>
-
#include <boost/preprocessor/logical/or.hpp>
-
#include <boost/preprocessor/logical/xor.hpp>
-
#include <boost/preprocessor/max.hpp>
-
#include <boost/preprocessor/min.hpp>
-
#include <boost/preprocessor/repeat.hpp>
-
#include <boost/preprocessor/repeat_2nd.hpp>
-
#include <boost/preprocessor/repeat_3rd.hpp>
-
#include <boost/preprocessor/repeat_from_to.hpp>
-
#include <boost/preprocessor/repeat_from_to_2nd.hpp>
-
#include <boost/preprocessor/repeat_from_to_3rd.hpp>
-
#include <boost/preprocessor/stringize.hpp>
-
#include <boost/preprocessor/tuple.hpp>
-
#include <boost/preprocessor/tuple/eat.hpp>
-
#include <boost/preprocessor/tuple/elem.hpp>
-
#include <boost/preprocessor/tuple/reverse.hpp>
-
#include <boost/preprocessor/tuple/to_list.hpp>
-
#include <boost/preprocessor/while.hpp>
-
- -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/limits.htm b/doc/reference/limits.htm deleted file mode 100644 index c07528c..0000000 --- a/doc/reference/limits.htm +++ /dev/null @@ -1,71 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/limits.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIMIT_DIM

-

Expands to the number of dimensions of repeat supported by the -library.

- -

This concerns the repetition primitives (BOOST_PP_ENUM(), -BOOST_PP_REPEAT() and BOOST_PP_REPEAT_FROM_TO()).

- -
- -

#define BOOST_PP_LIMIT_MAG

-

Expands to the maximum straight numeric literal supported by the -library.

- -

This is also the limit of the repetition primitives (BOOST_PP_ENUM(), -BOOST_PP_REPEAT() and BOOST_PP_REPEAT_FROM_TO()).

- -

Note

- - -
- -

#define BOOST_PP_LIMIT_TUPLE

-

Expands to the maximum tuple size supported by the library.

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list.htm b/doc/reference/list.htm deleted file mode 100644 index 3e93239..0000000 --- a/doc/reference/list.htm +++ /dev/null @@ -1,53 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list.hpp>

-
- -
- -Prev Next Macros Headers -
- -

Includes all list headers.

- -

A list is an arbitrary size collection of elements.

- -

In the preprocessor library, the internal representation of lists -uses parts that are like macro parameter lists. Thus an element of a list -can be any sequence of tokens that constitutes a single macro parameter.

- -

Lists are manipulated using both list ADT macros and higher-order macros. For an introduction to manipulation of lists in functional programming, see -[Thompson], -[Abelson] or -[Cousineau].

- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_adt.htm b/doc/reference/list_adt.htm deleted file mode 100644 index fa3e37f..0000000 --- a/doc/reference/list_adt.htm +++ /dev/null @@ -1,135 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/adt.hpp>

-
- -
- -Prev Next Macros Headers -
- -

This header defines the fundamental list operations.

- -

Note

-
    -
  • The internal representation of lists is hidden. Although there aren't - compelling reasons to change the representation, you should avoid - writing code that depends on the internal representation details.
  • -
- -
- -

#define BOOST_PP_LIST_CONS(FIRST,REST)

-

List constructor.

- -

Lists are build using list constructors BOOST_PP_LIST_NIL and -BOOST_PP_LIST_CONS(). For example,

- -
-BOOST_PP_LIST_CONS(1,
-BOOST_PP_LIST_CONS(2,
-BOOST_PP_LIST_CONS(3,
-BOOST_PP_LIST_CONS(4,
-BOOST_PP_LIST_CONS(5,
-BOOST_PP_LIST_NIL)))))
-
- -

Short lists can also be build from tuples:

- -
-BOOST_PP_TUPLE_TO_LIST(5,(1,2,3,4,5))
-
- -

Both of the above lists contain 5 elements: 1, 2, 3, 4 and 5.

- -

Longer lists can be built from short lists with BOOST_PP_LIST_APPEND_D() -and BOOST_PP_LIST_FOLD_RIGHT():

- -
-BOOST_PP_LIST_FOLD_RIGHT
-( BOOST_PP_LIST_APPEND_D
-, BOOST_PP_TUPLE_TO_LIST
-  ( N
-  , BOOST_PP_TUPLE_TO_LIST(M, (E11, E12, ..., E1M) )
-  , BOOST_PP_TUPLE_TO_LIST(M, (E21, E22, ..., E2M) )
-  , ...
-  , BOOST_PP_TUPLE_TO_LIST(M, (EN1, EN2, ..., ENM) )
-  )
-, BOOST_PP_LIST_NIL
-)
-
- -
- -

#define BOOST_PP_LIST_NIL

-

List nil constructor.

-
- -

#define BOOST_PP_LIST_IS_CONS(LIST)

-

Expands to 1 if the list is not nil and 0 otherwise.

-
- -

#define BOOST_PP_LIST_IS_NIL(LIST)

-

Expands to 1 if the list is nil and 0 otherwise.

-
- -

#define BOOST_PP_LIST_FIRST(LIST)

-

Expands to the first element of the list. The list must not be nil.

- -

For example,

- -
-BOOST_PP_LIST_FIRST(BOOST_PP_TUPLE_TO_LIST(5,(1,2,3,4,5)))
-
- -

expands to 1.

- -
- -

#define BOOST_PP_LIST_REST(LIST)

-

Expands to a list of all but the first element of the list.

- -

The list must not be nil.

- -

For example,

- -
-BOOST_PP_LIST_REST(BOOST_PP_TUPLE_TO_LIST(5,(1,2,3,4,5)))
-
- -

expands to the same as:

- -
-BOOST_PP_TUPLE_TO_LIST(4,(2,3,4,5))
-
- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_append.htm b/doc/reference/list_append.htm deleted file mode 100644 index a51caef..0000000 --- a/doc/reference/list_append.htm +++ /dev/null @@ -1,68 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/append.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_APPEND(LIST_1ST,LIST_2ND)

-

Catenates two lists together.

- -

For example,

- -
-BOOST_PP_LIST_APPEND
-( BOOST_PP_TUPLE_TO_LIST(2,(1,2))
-, BOOST_PP_TUPLE_TO_LIST(2,(3,4))
-)
-
- -

expands to the same as:

- -
-BOOST_PP_TUPLE_TO_LIST(4,(1,2,3,4))
-
- -

Test

- - -
- -

#define BOOST_PP_LIST_APPEND_D(D,LIST_1ST,LIST_2ND)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_at.htm b/doc/reference/list_at.htm deleted file mode 100644 index 1a92d1d..0000000 --- a/doc/reference/list_at.htm +++ /dev/null @@ -1,62 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/at.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_AT(LIST,INDEX)

-

Expands to the INDEX:th element of the list LIST. The -first element is at index 0.

- -

For example,

- -
-BOOST_PP_LIST_AT(BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)),1)
-
- -

expands to B.

- -

Test

- - -
- -

#define BOOST_PP_LIST_AT_D(D,LIST,INDEX)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_cat.htm b/doc/reference/list_cat.htm deleted file mode 100644 index c85d5b4..0000000 --- a/doc/reference/list_cat.htm +++ /dev/null @@ -1,65 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/cat.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_CAT(LIST)

-

Catenates all elements of the list.

- -

For example,

- -
-BOOST_PP_LIST_CAT(BOOST_PP_TUPLE_TO_LIST(3,(1,2,3)))
-
- -

expands to:

- -
-123
-
- -

Test

- - -
- -

#define BOOST_PP_LIST_CAT_D(D,LIST)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_enum.htm b/doc/reference/list_enum.htm deleted file mode 100644 index 0d41483..0000000 --- a/doc/reference/list_enum.htm +++ /dev/null @@ -1,65 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/enum.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_ENUM(LIST)

-

Converts the list to a comma separated list.

- -

For example,

- -
-BOOST_PP_LIST_ENUM(BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
-
- -

expands to:

- -
-A,B,C
-
- -

Uses

- - -
- -

#define BOOST_PP_LIST_ENUM_R(R,LIST)

-

Can be used inside BOOST_PP_FOR() (see for an explanation of the R parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_filter.htm b/doc/reference/list_filter.htm deleted file mode 100644 index d8b0d53..0000000 --- a/doc/reference/list_filter.htm +++ /dev/null @@ -1,66 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/filter.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_FILTER(PRED,DATA,LIST)

-

Expands to a list containing all the elements X of the list -for which PRED(D,DATA,X) is true.

- -

For example,

- -
-BOOST_PP_LIST_FILTER(BOOST_PP_NOT_EQUAL_D,2,BOOST_PP_TUPLE_TO_LIST(3,(1,2,3)))
-
- -

expands to the same as:

- -
-BOOST_PP_TUPLE_TO_LIST(2,(1,3))
-
- -

Test

- - -
- -

#define BOOST_PP_LIST_FILTER_D(D,PRED,DATA,LIST)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_first_n.htm b/doc/reference/list_first_n.htm deleted file mode 100644 index 572f10e..0000000 --- a/doc/reference/list_first_n.htm +++ /dev/null @@ -1,71 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/first_n.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_FIRST_N(COUNT,LIST)

-

Expands to a list of the first COUNT elements of the list -LIST.

- -

For example,

- -
-BOOST_PP_LIST_FIRST_N(2,BOOST_PP_TUPLE_TO_LIST(4,(+,-,*,/)))
-
- -

expands to the same as:

- -
-BOOST_PP_TUPLE_TO_LIST(2,(+,-))
-
- -

See

- - -

Test

- - -
- -

#define BOOST_PP_LIST_FIRST_N_D(D,COUNT,LIST)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_fold_left.htm b/doc/reference/list_fold_left.htm deleted file mode 100644 index 6c893b0..0000000 --- a/doc/reference/list_fold_left.htm +++ /dev/null @@ -1,103 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/fold_left.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_FOLD_LEFT(OP,STATE,LIST)

-

Iterates OP(D,STATE,X) for each element X of the -list LIST (from the left or the start of the list).

- -

In other words, expands to:

- -
-OP
-( D
-, ... OP(D, OP(D,STATE,BOOST_PP_LIST_AT(LIST,0)), BOOST_PP_LIST_AT(LIST,1)) ...
-, BOOST_PP_LIST_AT(LIST,BOOST_PP_DEC(BOOST_PP_LIST_SIZE(LIST))
-)
-
- -

For example,

- -
-#define TEST(D,STATE,X) BOOST_PP_CAT(STATE,X)
-BOOST_PP_LIST_FOLD_LEFT(TEST,_,BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
-
- -

expands to:

- -
-_ABC
-
- -

Note

-
    -
  • Folding, or accumulation, is a very general pattern of computation. - Most list operations can be implemented in terms of folding.
  • -
- -

See

- - -

Test

- - -
- -

#define BOOST_PP_LIST_FOLD_LEFT_D(D,OP,STATE,LIST)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

- -

Note

- - -
- -

#define BOOST_PP_LIST_FOLD_LEFT_2ND

-

Obsolete, just use BOOST_PP_LIST_FOLD_LEFT().

-
- -

#define BOOST_PP_LIST_FOLD_LEFT_2ND_D

-

Obsolete, just use BOOST_PP_LIST_FOLD_LEFT_D().

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_fold_left_2nd.htm b/doc/reference/list_fold_left_2nd.htm deleted file mode 100644 index 27f2a96..0000000 --- a/doc/reference/list_fold_left_2nd.htm +++ /dev/null @@ -1,46 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/fold_left_2nd.hpp>

-
- -
- -Prev Next Macros Headers -
- -

This header is obsolete. Use the following code instead.

- -
-#include <boost/preprocessor/list/fold_left.hpp>
-
- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_fold_right.htm b/doc/reference/list_fold_right.htm deleted file mode 100644 index 5c0fe4c..0000000 --- a/doc/reference/list_fold_right.htm +++ /dev/null @@ -1,106 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/fold_right.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_FOLD_RIGHT(OP,LIST,STATE)

-

Iterates OP(D,X,STATE) for each element X of the -list LIST (from the right or the end of the list).

- -

In other words, expands to:

- -
-OP
-( D
-, BOOST_PP_LIST_AT(LIST,0)
-, ... OP
-      ( D
-      , BOOST_PP_LIST_AT(LIST,BOOST_PP_SUB(BOOST_PP_LIST_SIZE(LIST),2))
-      , OP
-        ( D
-        , BOOST_PP_LIST_AT(LIST,BOOST_PP_SUB(BOOST_PP_LIST_SIZE(LIST),1))
-        , STATE
-        )
-      ) ...
-)
-
- -

For example,

- -
-#define TEST(D,X,STATE) BOOST_PP_CAT(STATE,X)
-BOOST_PP_LIST_FOLD_RIGHT(TEST,_,BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
-
- -

expands to:

- -
-_CBA
-
- -

Note

-
    -
  • Folding, or accumulation, is a very general pattern of computation. - Most list operations can be implemented in terms of folding.
  • -
- -

Test

- - -
- -

#define BOOST_PP_LIST_FOLD_RIGHT_D(D,OP,LIST,STATE)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

- -

Note

- - -
- -

#define BOOST_PP_LIST_FOLD_RIGHT_2ND

-

Obsolete, just use BOOST_PP_LIST_FOLD_RIGHT().

-
- -

#define BOOST_PP_LIST_FOLD_RIGHT_2ND_D

-

Obsolete, just use BOOST_PP_LIST_FOLD_RIGHT_D().

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_fold_right_2nd.htm b/doc/reference/list_fold_right_2nd.htm deleted file mode 100644 index 15f139f..0000000 --- a/doc/reference/list_fold_right_2nd.htm +++ /dev/null @@ -1,46 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/fold_right_2nd.hpp>

-
- -
- -Prev Next Macros Headers -
- -

This header is obsolete. Use the following code instead.

- -
-#include <boost/preprocessor/list/fold_right.hpp>
-
- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_for_each.htm b/doc/reference/list_for_each.htm deleted file mode 100644 index d5656f8..0000000 --- a/doc/reference/list_for_each.htm +++ /dev/null @@ -1,81 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/for_each.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_FOR_EACH(MACRO,DATA,LIST)

-

Repeats MACRO(R,DATA,BOOST_PP_LIST_AT(LIST,INDEX)) for each INDEX = [0, -BOOST_PP_LIST_SIZE(LIST)).

- -

In other words, expands to the sequence:

- -
-MACRO(R,DATA,BOOST_PP_LIST_AT(LIST,0))
-MACRO(R,DATA,BOOST_PP_LIST_AT(LIST,1))
-...
-MACRO(R,DATA,BOOST_PP_LIST_AT(LIST,BOOST_PP_DEC(BOOST_PP_LIST_SIZE(LIST))))
-
- -

For example,

- -
-#define TEST(R,DATA,X) BOOST_PP_CAT(DATA,X)();
-BOOST_PP_LIST_FOR_EACH(TEST,prefix_,BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
-
- -

expands to:

- -
-prefix_A(); prefix_B(); prefix_C();
-
- -

Example

- - -

Test

- - -
- -

#define BOOST_PP_LIST_FOR_EACH_R(R,MACRO,DATA,LIST)

-

Can be used inside BOOST_PP_FOR() (see for an explanation of the R parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_for_each_i.htm b/doc/reference/list_for_each_i.htm deleted file mode 100644 index b4b0ac0..0000000 --- a/doc/reference/list_for_each_i.htm +++ /dev/null @@ -1,71 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/for_each_i.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_FOR_EACH_I(MACRO,DATA,LIST)

-

Repeats MACRO(R,DATA,INDEX,BOOST_PP_LIST_AT(LIST,INDEX)) for each INDEX = [0, -BOOST_PP_LIST_SIZE(LIST)).

- -

In other words, expands to the sequence:

- -
-MACRO(R,DATA,0,BOOST_PP_LIST_AT(LIST,0))
-MACRO(R,DATA,1,BOOST_PP_LIST_AT(LIST,1))
-...
-MACRO(R,DATA,BOOST_PP_DEC(BOOST_PP_LIST_SIZE(LIST)),BOOST_PP_LIST_AT(LIST,BOOST_PP_DEC(BOOST_PP_LIST_SIZE(LIST))))
-
- -

For example,

- -
-#define TEST(R,DATA,INDEX,X) BOOST_PP_CAT(DATA,X)(INDEX);
-BOOST_PP_LIST_FOR_EACH_I(TEST,prefix_,BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
-
- -

expands to:

- -
-prefix_A(0); prefix_B(1); prefix_C(2);
-
- -
- -

#define BOOST_PP_LIST_FOR_EACH_I_R(R,MACRO,DATA,LIST)

-

Can be used inside BOOST_PP_FOR() (see for an explanation of the R parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_for_each_product.htm b/doc/reference/list_for_each_product.htm deleted file mode 100644 index e70e6e1..0000000 --- a/doc/reference/list_for_each_product.htm +++ /dev/null @@ -1,82 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/for_each_product.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_FOR_EACH_PRODUCT(MACRO,SIZE_OF_TUPLE,TUPLE_OF_LISTS)

-

Repeats MACRO(R,X) for each element X of the -cartesian product of the lists of the SIZE_OF_TUPLE-tuple TUPLE_OF_LISTS.

- -

This macro is useful for generating code to avoid combinatorial -explosion.

- -

For example,

- -
-#define TEST(R,X) X
-BOOST_PP_LIST_FOR_EACH_PRODUCT
-( TEST
-, 2
-, ( BOOST_PP_TUPLE_TO_LIST(3,(A,B,C))
-  , BOOST_PP_TUPLE_TO_LIST(2,(1,2))
-  )
-)
-
- -

expands to:

- -
-(A,1) (A,2) (B,1) (B,2) (C,1) (C,2) 
-
- -

Example

- - -

Test

- - -
- -

#define BOOST_PP_LIST_FOR_EACH_PRODUCT_R(R,MACRO,SIZE_OF_TUPLE,TUPLE_OF_LISTS)

-

Can be used inside BOOST_PP_FOR() (see for an explanation of the R parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_rest_n.htm b/doc/reference/list_rest_n.htm deleted file mode 100644 index e15dd24..0000000 --- a/doc/reference/list_rest_n.htm +++ /dev/null @@ -1,71 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/rest_n.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_REST_N(COUNT,LIST)

-

Expands to a list of all but the first COUNT elements of the -list LIST.

- -

For example,

- -
-BOOST_PP_LIST_REST_N(2,BOOST_PP_TUPLE_TO_LIST(4,(+,-,*,/)))
-
- -

expands to the same as:

- -
-BOOST_PP_TUPLE_TO_LIST(2,(*,/))
-
- -

See

- - -

Test

- - -
- -

#define BOOST_PP_LIST_REST_N_D(D,COUNT,LIST)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_reverse.htm b/doc/reference/list_reverse.htm deleted file mode 100644 index 1e395fc..0000000 --- a/doc/reference/list_reverse.htm +++ /dev/null @@ -1,65 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/reverse.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_REVERSE(LIST)

-

List reversal.

- -

For example,

- -
-BOOST_PP_LIST_REVERSE(BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
-
- -

expands to the same as:

- -
-BOOST_PP_TUPLE_TO_LIST(3,(C,B,A))
-
- -

Test

- - -
- -

#define BOOST_PP_LIST_REVERSE_D(D,LIST)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_size.htm b/doc/reference/list_size.htm deleted file mode 100644 index 5135860..0000000 --- a/doc/reference/list_size.htm +++ /dev/null @@ -1,61 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/size.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_SIZE(LIST)

-

Expands to the number of elements in the list.

- -

For example,

- -
-BOOST_PP_LIST_SIZE(BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
-
- -

expands to 3.

- -

Test

- - -
- -

#define BOOST_PP_LIST_SIZE_D(D,LIST)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_to_tuple.htm b/doc/reference/list_to_tuple.htm deleted file mode 100644 index 5794af0..0000000 --- a/doc/reference/list_to_tuple.htm +++ /dev/null @@ -1,67 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/to_tuple.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_TO_TUPLE(LIST)

-

Converts the list to a tuple.

- -

For example,

- -
-BOOST_PP_LIST_TO_TUPLE(BOOST_PP_TUPLE_TO_LIST(3,(A,B,C)))
-
- -

expands to (A,B,C).

- -

Note

- - -

Test

- - -
- -

#define BOOST_PP_LIST_TO_TUPLE_R(R,LIST)

-

Can be used inside BOOST_PP_FOR() (see for an explanation of the R parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/list_transform.htm b/doc/reference/list_transform.htm deleted file mode 100644 index bc40484..0000000 --- a/doc/reference/list_transform.htm +++ /dev/null @@ -1,76 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/list/transform.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_LIST_TRANSFORM(OP,DATA,LIST)

-

Applies the macro OP(D,DATA,X) to each element X -of the list producing a new list.

- -

In other words, expands to:

- -
-BOOST_PP_LIST_CONS(OP(D,DATA,BOOST_PP_LIST_AT(LIST,0)),
-BOOST_PP_LIST_CONS(OP(D,DATA,BOOST_PP_LIST_AT(LIST,1)),
-...
-BOOST_PP_LIST_CONS(OP(D,DATA,BOOST_PP_LIST_AT(LIST,BOOST_PP_DEC(BOOST_PP_LIST_SIZE(LIST)))),
-BOOST_PP_LIST_NIL) ... ))
-
- -

For example,

- -
-BOOST_PP_LIST_TRANSFORM(BOOST_PP_ADD_D,2,BOOST_PP_TUPLE_TO_LIST(2,(1,2)))
-
- -

expands to the same as:

- -
-BOOST_PP_TUPLE_TO_LIST(2,(3,4))
-
- -

Test

- - -
- -

#define BOOST_PP_LIST_TRANSFORM_D(D,OP,DATA,LIST)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/logical.htm b/doc/reference/logical.htm deleted file mode 100644 index 2f5f6c1..0000000 --- a/doc/reference/logical.htm +++ /dev/null @@ -1,41 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/logical.hpp>

-
- -
- -Prev Next Macros Headers -
- -

Includes all logical headers.

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/logical_and.htm b/doc/reference/logical_and.htm deleted file mode 100644 index 36e6bad..0000000 --- a/doc/reference/logical_and.htm +++ /dev/null @@ -1,54 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/logical/and.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_AND(X,Y)

-

Expands to the logical AND of the operands.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_AND(0,5) expands to 0 (a single token).

- -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/logical_bool.htm b/doc/reference/logical_bool.htm deleted file mode 100644 index ec5e230..0000000 --- a/doc/reference/logical_bool.htm +++ /dev/null @@ -1,48 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/logical/bool.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_BOOL(X)

-

Expands to 0 if X == 0 and 1 if X != 0.

- -

X must be an integer literal in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_BOOL(3) expands to 1.

- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/logical_nor.htm b/doc/reference/logical_nor.htm deleted file mode 100644 index 1a6c790..0000000 --- a/doc/reference/logical_nor.htm +++ /dev/null @@ -1,54 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/logical/nor.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_NOR(X,Y)

-

Expands to the logical NEITHER OR of the operands.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_NOR(0,5) expands to 0 (a single token).

- -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/logical_not.htm b/doc/reference/logical_not.htm deleted file mode 100644 index 99c0293..0000000 --- a/doc/reference/logical_not.htm +++ /dev/null @@ -1,53 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/logical/not.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_NOT(X)

-

Expands to the logical NOT of the operand.

- -

X must be an integer literal in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_NOT(0) expands to 1 (a single token).

- -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/logical_or.htm b/doc/reference/logical_or.htm deleted file mode 100644 index f54fcd0..0000000 --- a/doc/reference/logical_or.htm +++ /dev/null @@ -1,54 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/logical/or.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_OR(X,Y)

-

Expands to the logical OR of the operands.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_OR(0,2) expands to 1 (a single token).

- -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/logical_xor.htm b/doc/reference/logical_xor.htm deleted file mode 100644 index 6dc59bb..0000000 --- a/doc/reference/logical_xor.htm +++ /dev/null @@ -1,54 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/logical/xor.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_XOR(X,Y)

-

Expands to the logical EXCLUSIVE OR of the operands.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_XOR(1,2) expands to 0 (a single token).

- -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/max.htm b/doc/reference/max.htm deleted file mode 100644 index ee15baa..0000000 --- a/doc/reference/max.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/max.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_MAX(X,Y)

-

Expands to the maximum of X and Y.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_MAX(5,7) expands to 7 (a -single token).

- -

Test

- - -
- -

#define BOOST_PP_MAX_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/min.htm b/doc/reference/min.htm deleted file mode 100644 index 12cdd5c..0000000 --- a/doc/reference/min.htm +++ /dev/null @@ -1,59 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/min.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_MIN(X,Y)

-

Expands to the minimum of X and Y.

- -

Both X and Y must expand to integer literals -in the range [0, BOOST_PP_LIMIT_MAG].

- -

For example, BOOST_PP_MIN(5,7) expands to 5 (a -single token).

- -

Test

- - -
- -

#define BOOST_PP_MIN_D(D,X,Y)

-

Can be used inside BOOST_PP_WHILE() (see for an explanation of the D parameter).

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/repeat.htm b/doc/reference/repeat.htm deleted file mode 100644 index e0d959c..0000000 --- a/doc/reference/repeat.htm +++ /dev/null @@ -1,95 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/repeat.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_REPEAT(COUNT,MACRO,DATA)

-

Repeats the macro MACRO(INDEX,DATA) for INDEX = [0,COUNT).

- -

In other words, expands to the sequence:

- -
-MACRO(0,DATA) MACRO(1,DATA) ... MACRO(BOOST_PP_DEC(COUNT),DATA)
-
- -

For example,

- -
-#define TEST(INDEX,DATA) DATA(INDEX);
-BOOST_PP_REPEAT(3,TEST,X)
-
- -

expands to:

- -
-X(0); X(1); X(2);
-
- -

2D and 3D repetition

- -

BOOST_PP_REPEAT() implements automatic recursion. 2D and 3D repetition -are directly supported.

- -

Example

- - -

See

- - -

Test

- - -
- -

#define BOOST_PP_REPEAT_2ND

-

Obsolete, just use BOOST_PP_REPEAT().

-
- -

#define BOOST_PP_REPEAT_3RD

-

Obsolete, just use BOOST_PP_REPEAT().

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/repeat_2nd.htm b/doc/reference/repeat_2nd.htm deleted file mode 100644 index 4ddaf5b..0000000 --- a/doc/reference/repeat_2nd.htm +++ /dev/null @@ -1,46 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/repeat_2nd.hpp>

-
- -
- -Prev Next Macros Headers -
- -

This header is obsolete. Use the following code instead.

- -
-#include <boost/preprocessor/repeat.hpp>
-
- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/repeat_3rd.htm b/doc/reference/repeat_3rd.htm deleted file mode 100644 index 62754fd..0000000 --- a/doc/reference/repeat_3rd.htm +++ /dev/null @@ -1,46 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/repeat_3rd.hpp>

-
- -
- -Prev Next Macros Headers -
- -

This header is obsolete. Use the following code instead.

- -
-#include <boost/preprocessor/repeat.hpp>
-
- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/repeat_from_to.htm b/doc/reference/repeat_from_to.htm deleted file mode 100644 index 85074a7..0000000 --- a/doc/reference/repeat_from_to.htm +++ /dev/null @@ -1,89 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/repeat_from_to.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_REPEAT_FROM_TO(FIRST,LAST,MACRO,DATA)

-

Repeats the macro MACRO(INDEX,DATA) for INDEX = [FIRST,LAST).

- -

In other words, expands to the sequence:

- -
-MACRO(FIRST,DATA) MACRO(BOOST_PP_INC(FIRST),DATA) ... MACRO(BOOST_PP_DEC(LAST),DATA)
-
- -

For example,

- -
-#define TEST(INDEX,DATA) DATA(INDEX);
-BOOST_PP_REPEAT_FROM_TO(4,7,TEST,X)
-
- -

expands to:

- -
-X(4); X(5); X(6);
-
- -

2D and 3D repetition

- -

BOOST_PP_REPEAT_FROM_TO() implements automatic recursion. 2D and 3D repetition -are directly supported.

- -

See

- - -

Test

- - -
- -

#define BOOST_PP_REPEAT_FROM_TO_2ND

-

Obsolete, just use BOOST_PP_REPEAT_FROM_TO().

-
- -

#define BOOST_PP_REPEAT_FROM_TO_3RD

-

Obsolete, just use BOOST_PP_REPEAT_FROM_TO().

-
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/repeat_from_to_2nd.htm b/doc/reference/repeat_from_to_2nd.htm deleted file mode 100644 index 58029c9..0000000 --- a/doc/reference/repeat_from_to_2nd.htm +++ /dev/null @@ -1,46 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/repeat_from_to_2nd.hpp>

-
- -
- -Prev Next Macros Headers -
- -

This header is obsolete. Use the following code instead.

- -
-#include <boost/preprocessor/repeat_from_to.hpp>
-
- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/repeat_from_to_3rd.htm b/doc/reference/repeat_from_to_3rd.htm deleted file mode 100644 index 741dbcc..0000000 --- a/doc/reference/repeat_from_to_3rd.htm +++ /dev/null @@ -1,46 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/repeat_from_to_3rd.hpp>

-
- -
- -Prev Next Macros Headers -
- -

This header is obsolete. Use the following code instead.

- -
-#include <boost/preprocessor/repeat_from_to.hpp>
-
- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/stringize.htm b/doc/reference/stringize.htm deleted file mode 100644 index 17430ad..0000000 --- a/doc/reference/stringize.htm +++ /dev/null @@ -1,56 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/stringize.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_STRINGIZE(X)

-

Stringizes X after it is macro expanded.

- -

For example, BOOST_PP_STRINGIZE(BOOST_PP_CAT(a,b)) expands to "ab".

- -

Example

- - -

Test

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/tuple.htm b/doc/reference/tuple.htm deleted file mode 100644 index d5faebb..0000000 --- a/doc/reference/tuple.htm +++ /dev/null @@ -1,58 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/tuple.hpp>

-
- -
- -Prev Next Macros Headers -
- -

Includes all tuple headers.

- -

A tuple is a fixed size collection of elements.

- -

In the preprocessor library, tuples are represented like macro parameter -lists. Thus an element of a tuple can be any sequence of tokens that -constitutes a single macro parameter.

- -

Examples of tuples:

- -
-(const, volatile)    // 2-tuple
-(*, /, %)            // 3-tuple
-(1, "2", '3', (4,5)) // 4-tuple
-
- -

Tuples can be used for representing structured data.

- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/tuple_eat.htm b/doc/reference/tuple_eat.htm deleted file mode 100644 index 4861c02..0000000 --- a/doc/reference/tuple_eat.htm +++ /dev/null @@ -1,55 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/tuple/eat.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_TUPLE_EAT(SIZE_OF_TUPLE)

-

Expands to a macro that eats a tuple of the specified size.

- -

BOOST_PP_TUPLE_EAT() is designed to be used with BOOST_PP_IF() like -BOOST_PP_EMPTY().

- -

For example,

- -
-BOOST_PP_IF(0,BOOST_PP_ENUM_PARAMS,BOOST_PP_TUPLE_EAT(2))(10,P)
-
- -

expands to nothing.

- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/tuple_elem.htm b/doc/reference/tuple_elem.htm deleted file mode 100644 index e3996f9..0000000 --- a/doc/reference/tuple_elem.htm +++ /dev/null @@ -1,57 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/tuple/elem.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_TUPLE_ELEM(SIZE_OF_TUPLE,INDEX,TUPLE)

-

Expands to the INDEX:th element of an SIZE_OF_TUPLE-tuple.

- -

For example,

- -
-BOOST_PP_TUPLE_ELEM(2,1,(A,B))
-
- -

expands to B.

- -

See

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/tuple_reverse.htm b/doc/reference/tuple_reverse.htm deleted file mode 100644 index 466057b..0000000 --- a/doc/reference/tuple_reverse.htm +++ /dev/null @@ -1,52 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/tuple/reverse.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_TUPLE_REVERSE(SIZE_OF_TUPLE,TUPLE)

-

Tuple reversal.

- -

For example,

- -
-BOOST_PP_TUPLE_REVERSE(3,(A,B,C))
-
- -

expands to (C,B,A).

- -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/tuple_to_list.htm b/doc/reference/tuple_to_list.htm deleted file mode 100644 index e36a38f..0000000 --- a/doc/reference/tuple_to_list.htm +++ /dev/null @@ -1,64 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/tuple/to_list.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_TUPLE_TO_LIST(SIZE_OF_TUPLE,TUPLE)

-

Converts a tuple to a list.

- -

For example,

- -
-BOOST_PP_TUPLE_TO_LIST(3,(A,B,C))
-
- -

expands to the same as

- -
-BOOST_PP_LIST_CONS(A,
-BOOST_PP_LIST_CONS(B,
-BOOST_PP_LIST_CONS(C,
-BOOST_PP_LIST_NIL)))
-
- -

See

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/reference/while.htm b/doc/reference/while.htm deleted file mode 100644 index 8527beb..0000000 --- a/doc/reference/while.htm +++ /dev/null @@ -1,107 +0,0 @@ - - - - -Boost.Preprocessor - Reference - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Header <boost/preprocessor/while.hpp>

-
- -
- -Prev Next Macros Headers - -
- -

#define BOOST_PP_WHILE(PRED,OP,STATE)

-

Iterates OP(D,STATE) while PRED(D,STATE) is true.

- -

In other words, expands to:

- -
-OP(D, ... OP(D, OP(D,STATE) ) ... )
-
- -

The depth of iteration is determined by PRED(D,STATE).

- -

For example,

- -
-#define PRED(D,STATE) BOOST_PP_LESS_D(D,BOOST_PP_TUPLE_ELEM(2,0,STATE),BOOST_PP_TUPLE_ELEM(2,1,STATE))
-#define OP(D,STATE) (BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(2,0,STATE)),BOOST_PP_TUPLE_ELEM(2,1,STATE))
-BOOST_PP_WHILE(PRED,OP,(0,3))
-
- -

expands to:

- -
-(3,3)
-
- -

Legend

-
    -
  • STATE is the current state of iteration. The state is usually a tuple.
  • -
  • PRED is the condition for iteration. It must expand to a decimal - integer literal.
  • -
  • OP is the iterated macro. Note that if the state is a tuple, then - OP(D,STATE) usually expands to a tuple of the same number of elements.
  • -
  • D is the recursion depth and should only be used as a parameter - to other macros using BOOST_PP_WHILE(). Such macros include - BOOST_PP_ADD() and other arithmetic operations. For each macro using - BOOST_PP_WHILE(), there is a version of the macro, distinguished by the - D suffix (e.g. BOOST_PP_ADD_D()), that accepts an additional recursion - depth as the first parameter. This technique is necessary to avoid - recursively expanding the same macro again, which is not permitted by the - C++ preprocessor.
  • -
- -

Automatic recursion?

- -

BOOST_PP_WHILE() currently does not implement automatic recursion. The reason -for this is that it would lead to very poor performance. The automatic recursion -technique takes O(N) steps just to find out that the Nth recursion should be used. -This would dramatically effect the time complexity of macros using automatic -recursion.

- -

Note

-
    -
  • The value of the D parameter may exceed BOOST_PP_LIMIT_MAG.
  • -
  • Using BOOST_PP_WHILE() is a bit tricky. This is due to the C++ - preprocessor limitations. It is recommended to take a look at the - implementations of the various PREPROCESSOR library primitives - such as BOOST_PP_ADD() for additional examples.
  • -
- -

Example

- - -
- -Prev Next Macros Headers -
- -

Revised

- -

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/doc/tutorial.htm b/doc/tutorial.htm deleted file mode 100644 index c803cbd..0000000 --- a/doc/tutorial.htm +++ /dev/null @@ -1,478 +0,0 @@ - - - - -Boost.Preprocessor - Tutorial - - - - - - - -
-

C++ Boost

-
-

Boost.Preprocessor

-

Tutorial

-
-
- -

Contents

-
-
Motivation
-
Preprocessor Metaprogramming Techniques -
-
Use a Local Macro to avoid small scale repetition
-
Use BOOST_PP_EMPTY as an unused parameter in Local - Macro instantiations
-
Use BOOST_PP_CAT instead of ## when necessary
-
Use BOOST_PP_STRINGIZE instead of # whenever necessary
-
Avoid O(N) repetition on lists in general
-
Use a Conditional Define to enable user configuration of code repetition
-
Use Token Look-Up Function to eliminate categorical repetition
-
Use BOOST_PP_REPEAT to avoid O(N*N) repetition
-
Use BOOST_PP_IF to implement special case for the first element
-
Use arithmetic, logical and comparison operations when necessary
-
-
-
- -
- -

Motivation

- -

The C++ function and template parameter lists are special syntactic constructs - and it is impossible to directly manipulate or generate them using C++ constructs. - This leads to unnecessary code repetition.

-

Consider the implementation of the is_function<> metafunction in Boost. The - implementation uses an overloaded is_function_tester() function that is used - for testing if a type is convertible to pointer to a function. Because of the - special treatment of parameter lists, it is not possible to directly match a - function with an arbitrary parameter list. Instead, the is_function_tester() - must be overloaded for every distinct number of parameters that is to be supported. - Example:

- -
template <class R>
-yes_type is_function_tester(R (*)());
-template <class R, class A0>
-yes_type is_function_tester(R (*)(A0));
-template <class R, class A0, A1>
-yes_type is_function_tester(R (*)(A0, A1));
-template <class R, class A0, A1, A2>
-yes_type is_function_tester(R (*)(A0, A1, A2));
-
-// ...
-
- -

The need for this kind of repetition occurs particularly frequently while implementing - generic components or metaprogramming facilities, but the need also manifests - itself in many far simpler situations.

- -

Typical solutions

- -

Typically the repetition is done manually. Manual code repetition is highly - unproductive, but sometimes more readable to the untrained eye.

-

Another solution is to write an external program for generating the repeated - code or use some other extra linquistic means such as a smart editor. Unfortunately, - using external code generators has many disadvantages:

-
    -
  • writing the generator takes time (this could be helped by using a standard - generator)
  • -
  • it is no longer productive to manipulate C++ code directly
  • -
  • invoking the generator may be difficult
  • -
  • automating the invocation of the generator can be difficult in certain environments - (automatic invocation is desirable for active libraries)
  • -
  • porting and distributing the generator may be difficult or simply takes - precious time
  • -
-

What about the preprocessor?

-

Because C++ comes with a preprocessor, one would assume that it would support - these kind of needs directly. Using the preprocessor in this case is highly - desirable because:

-
    -
  • preprocessor is highly portable
  • -
  • preprocessor is automatically invoked as part of the compiling process
  • -
  • preprocessor metacode can be directly embedded into the C++ source code
  • -
  • Compilers generally allow to view or output the preprocessed code, which - can be used for debugging or to copy-paste the generated code.
  • -
-

Most unfortunately, the preprocessor is a very low level preprocessor that - specifically does not support repetition or recursive macros. Library support - is needed!

-

For detailed information on the capabilities and limitations of the preprocessor, - please refer to the C++ standard [Std].

-

The motivation example revisited

-

Using the primitives of the PREPROCESSOR library, the is_function_tester()s - could be implemented like this:

- -
#define IS_FUNCTION_TESTER(N,_)\
-  template<class R BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, class A)>\
-  yes_type is_function_tester(R (*)(BOOST_PP_ENUM_PARAMS(N,A)));
-
-BOOST_PP_REPEAT(BOOST_PP_INC(MAX_IS_FUNCTION_TESTER_PARAMS),IS_FUNCTION_TESTER,_)
-#undef IS_FUNCTION_TESTER
-
- -

In order to change the maximum number of function parameters supported, you - now simply change the MAX_IS_FUNCTION_TESTER_PARAMS definition and recompile.

-
- -

Preprocessor Metaprogramming Techniques

-

The preprocessor metaprogramming techniques are presented in example format. -

-
-

EXAMPLE: - Use a Local Macro to avoid small scale repetition

- -
#define BOOST_PP_DEF(OP)   \
-  template<class T, int n> \
-  vec<T,n>&                \
-    operator OP##=         \
-    ( vec<T,n>&            \
-        lhs                \
-    , const vec<T,n>&      \
-        rhs                \
-    )                      \
-  { for (int i=0; i<n; ++i)\
-      lhs(i) OP##= rhs(i); \
-    return lhs;            \
-  }
-
-BOOST_PP_DEF(+)
-BOOST_PP_DEF(-)
-BOOST_PP_DEF(*)
-BOOST_PP_DEF(/)
-#undef BOOST_PP_DEF
-
- -

TIP: It is usually okay to use a standard macro name like BOOST_PP_DEF - for this kind of code, because the macro is both defined and undefined in the - immediate site of its use.

-

TIP: It is easier to verify proper use of -the line continuation operator when they are aligned.

-

NOTES: You can extend this example by defining more and different kinds - of operators. Before doing so, consider using the Algebraic Categories technique - introduced in [Barton] or a Layered Architecture (see for instance - [Czarnecki]). However, at some point you must type the operator tokens - *, /, +, -, ..., because it is impossible to generate them using templates. - The resulting Categorical Repetition of tokens can be eliminated by using preprocessor - metaprogramming.

-
-

EXAMPLE: - Use BOOST_PP_EMPTY as an unused parameter in Local Macro instantiations

- -
#define BOOST_PP_DEF(CV)  \
-  template<class base>    \
-  CV() typename implement_subscript_using_begin_subscript<base>::value_type&\
-    implement_subscript_using_begin_subscript<base>::operator[]\
-    ( index_type          \
-        i                 \
-    ) CV()                \
-{ return base::begin()[i];\
-}
-
-BOOST_PP_DEF(BOOST_PP_EMPTY)
-BOOST_PP_DEF(const BOOST_PP_EMPTY)
-#undef BOOST_PP_DEF
-
- -

HOW: BOOST_PP_EMPTY() expands to nothing and can be used as - an unused parameter.

-

NOTE: BOOST_PP_EMPTY without the () never gets expanded. The - () is necessary to invoke a function-like macro.

-CAVEAT: You can not safely use concatenation while using BOOST_PP_EMPTY(). -

TIP: Occasionally one or two lines are -considerably longer than the rest. It can often save some work to not align all -of the line continuation operators without making the code too unreadable.

-

TIP: Use syntax highlighting on preprocessor metaprogramming macro and - parameter identifiers such as

-
    -
  • BOOST_PP_DEF,
  • -
  • BOOST_PP_EMPTY,
  • -
  • BOOST_PP_REPEAT,
  • -
  • OP,
  • -
  • CV,
  • -
  • ...
  • -
-

It can greatly improve readability.

-
-

EXAMPLE: Use BOOST_PP_CAT instead of ## when necessary

- -
#define STATIC_ASSERT(EXPR)\
-  enum\
-  { BOOST_PP_CAT(static_check_,__LINE__) = (EXPR) ? 1 : -1\
-  };\
-  typedef char\
-    BOOST_PP_CAT(static_assert_,__LINE__)\
-    [ BOOST_PP_CAT(static_check_,__LINE__)\
-    ]
-
-// ...
-
-STATIC_ASSERT(sizeof(int) <= sizeof(long));
-
- -

WHY: Macro expansion proceeds recursively in "layers". Token pasting - prevents the preprocessor from performing macro expansion, therefore it - is often necessary to delay token concatenation.

-
-

EXAMPLE: Use BOOST_PP_STRINGIZE instead of # whenever necessary

- -
#define NOTE(STR)\
-  message(__FILE__ "(" BOOST_PP_STRINGIZE(__LINE__) ") : " STR)
-
-// ...
-
-#pragma NOTE("TBD!")
-
- -

WHY: Macro expansion proceeds recursively in "layers". Stringization - prevents the preprocessor from performing macro expansion, therefore it is often - necessary to delay stringization.

-
-

EXAMPLE: - Use:

-
    -
  • BOOST_PP_ENUM_PARAMS,
  • -
  • BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT,
  • -
  • BOOST_PP_ENUM_PARAMS_WITH_DEFAULTS,
  • -
  • BOOST_PP_ENUM_SHIFTED_PARAMS, or
  • -
  • BOOST_PP_REPEAT, and
  • -
  • BOOST_PP_COMMA_IF
  • -
-

to avoid O(N) repetition on lists in general

- -
struct make_type_list_end;
-
-template
-< BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT
-  ( MAKE_TYPE_LIST_MAX_LENGTH
-  , class T
-  , make_type_list_end
-  )
->
-struct make_type_list
-{
-private:
-  enum
-  { end = is_same<T0,make_type_list_end>::value
-  };
-
-public:
-  typedef typename
-    type_if
-    < end
-    , type_cons_empty
-    , type_cons
-      < T0
-      , typename
-        type_inner_if
-        < end
-        , type_identity<end>
-        , make_type_list
-          < BOOST_PP_ENUM_SHIFTED_PARAMS
-            ( MAKE_TYPE_LIST_MAX_LENGTH
-            , T
-            )
-          >
-        >::type
-      >
-    >::type type;
-};
-
- -

HOW: BOOST_PP_REPEAT uses simulated recursion (pseudo code):

- -
#define BOOST_PP_REPEAT(N,M,P) BOOST_PP_REPEAT##N(M,P)
-#define BOOST_PP_REPEAT0(M,P)
-#define BOOST_PP_REPEAT1(M,P) M(0,P)
-#define BOOST_PP_REPEAT2(M,P) M(0,P) M(1,P)
-#define BOOST_PP_REPEAT3(M,P) BOOST_PP_REPEAT2(M,P) M(2,P)
-#define BOOST_PP_REPEAT4(M,P) BOOST_PP_REPEAT3(M,P) M(3,P)
-// ...
-
- -

BOOST_PP_ENUM_PARAMS variations use BOOST_PP_REPEAT

- -

BOOST_PP_COMMA_IF(I) expands to a comma if I != 0.

- -

BOOST_PP_INC(I) expands essentially to "I+1" and BOOST_PP_DEC(I) - expands essentially to "I-1".

- -
- -

EXAMPLE: Use a Conditional Define to -enable user configuration of code repetition based on need rather than some -"reasonable" upper limit

- -
#ifndef MAKE_TYPE_LIST_MAX_LENGTH
-#define MAKE_TYPE_LIST_MAX_LENGTH 8
-#endif
-
- -

Now the user can configure the make_type_list primitive without modifying library - code.

-
-

EXAMPLE: - Use BOOST_PP_REPEAT and a Token Look-Up Function to eliminate categorical - repetition

- -
// CAVEAT: My compiler is not standard on arithmetic types.
-#define ARITHMETIC_TYPE(I)  ARITHMETIC_TYPE##I
-#define ARITHMETIC_TYPE0    bool
-#define ARITHMETIC_TYPE1    char
-#define ARITHMETIC_TYPE2    signed char
-#define ARITHMETIC_TYPE3    unsigned char
-#define ARITHMETIC_TYPE4    short
-#define ARITHMETIC_TYPE5    unsigned short
-#define ARITHMETIC_TYPE6    int
-#define ARITHMETIC_TYPE7    unsigned int
-#define ARITHMETIC_TYPE8    long
-#define ARITHMETIC_TYPE9    unsigned long
-#define ARITHMETIC_TYPE10   float
-#define ARITHMETIC_TYPE11   double
-#define ARITHMETIC_TYPE12   long double
-#define ARITHMETIC_TYPE_CNT 13
-
-//  ...
-
-#define BOOST_PP_DEF(I,_)\
-catch (ARITHMETIC_TYPE(I) t)\
-{ report_typeid(t);\
-  report_value(t);\
-}
-BOOST_PP_REPEAT
-( ARITHMETIC_TYPE_CNT
-, BOOST_PP_DEF
-, _
-)
-#undef BOOST_PP_DEF
-
-// ...
-
- -

NOTE: The repetition of the above -example can be eliminated using template metaprogramming [Czarnecki] as well. However -categorical repetition of operator tokens can not be completely eliminated by -using template metaprogramming.

-
-

EXAMPLE: - Use BOOST_PP_REPEAT to avoid O(N*N) repetition

- -
#ifndef MAX_VEC_ARG_CNT
-#define MAX_VEC_ARG_CNT 8
-#endif
-
-//  ...
-
-#define ARG_FUN(I,_) BOOST_PP_COMMA_IF(I) T a##I
-#define ASSIGN_FUN(I,_) (*this)[I] = a##I;
-
-#define DEF_VEC_CTOR_FUN(I,_)\
-vec( BOOST_PP_REPEAT(I,ARG_FUN,_) )\
-{ BOOST_PP_REPEAT(I,ASSIGN_FUN,_)\
-}
-
-BOOST_PP_REPEAT
-( BOOST_PP_INC(MAX_VEC_ARG_CNT)
-, DEF_VEC_CTOR_FUN
-, _
-)
-
-#undef ARG_FUN
-#undef ASSIGN_FUN
-#undef DEF_VEC_CTOR_FUN
-
-// ...
-
- -

HOW: BOOST_PP_REPEAT is implemented in a special way to enable -automatic recursion.

- -
- -

EXAMPLE: Use BOOST_PP_IF to implement special case for the first element

- -
#define BOOST_PP_COMMA_IF(C)\
-  BOOST_PP_IF(C,BOOST_PP_COMMA,BOOST_PP_EMPTY)()
-
-BOOST_PP_IF(0,true,false) == false;
-BOOST_PP_IF(1,true,false) == true;
-
- -

BOOST_PP_IF enables convenient generation of lists using BOOST_PP_REPEAT.

- -

NOTE: THEN and ELSE don't have to be macros. However, if at least one - of them is a function-like macro and you want it to be expanded conditionally, - you have to make the other parameter a function-like macro, too. This can often - be done using BOOST_PP_IDENTITY. Consider the following example (by - Aleksey Gurtovoy):

- -
#define NUMBERED_EXPRESSION(I,X)\
-  BOOST_PP_IF                   \
-  ( I                           \
-  , BOOST_PP_IDENTITY(X##I)     \
-  , BOOST_PP_EMPTY              \
-  )()
- -

NOTE: Like in the above implementation of COMMA_IF, the result of IF - is often invoked and not the THEN and ELSE parameters. If the parameters were - invoked, the code would not expand correctly, because the EMPTY parameter would - get expanded to nothing before the IF would be properly expanded.

-

HOW: BOOST_PP_IF is defined for the entire repeat range (pseudo - code):

- -
#define BOOST_PP_IF(C,THEN,ELSE) BOOST_PP_IF##C(THEN,ELSE)
-#define BOOST_PP_IF0(THEN,ELSE) ELSE
-#define BOOST_PP_IF1(THEN,ELSE) THEN
-#define BOOST_PP_IF2(THEN,ELSE) THEN
-// ...
-
- -
- -

EXAMPLE: Use arithmetic, logical and comparison operations when necessary

- -

The PREPROCESSOR library supports saturated arithmetic, logical and -comparison operations on decimal integer literals in the range [0,BOOST_PP_LIMIT_MAG].

- -

Suppose that you want to generate a numbered lists with a special element inserted - at a desired position. For example: E0, E1, S, E2. Consider the following example:

- -
#define SPECIAL_NUMBERED_LIST(N,I,ELEM,SPECIAL)\
-  BOOST_PP_ASSERT_MSG(BOOST_PP_LESS(I,N),BAD PARAMS FOR SPECIAL_NUMBERED_LIST!)\
-  BOOST_PP_ENUM_PARAMS(I,ELEM)\
-  BOOST_PP_COMMA_IF(I) SPECIAL\
-  BOOST_PP_REPEAT(BOOST_PP_SUB(\
-    BOOST_PP_DEC(N),I),SPECIAL_NUMBERED_LIST_HELPER,(ELEM,I))
-#define SPECIAL_NUMBERED_LIST_HELPER(I,ELEM_BASE)\
-  ,\
-  BOOST_PP_CAT\
-  ( BOOST_PP_TUPLE_ELEM(2,0,ELEM_BASE)\
-  , BOOST_PP_ADD\
-    ( I\
-    , BOOST_PP_TUPLE_ELEM(2,1,ELEM_BASE)\
-    )\
-  )
-
-SPECIAL_NUMBERED_LIST(3,0,E,S)
-SPECIAL_NUMBERED_LIST(3,1,E,S)
-SPECIAL_NUMBERED_LIST(3,2,E,S)
-SPECIAL_NUMBERED_LIST(3,3,E,S)
-
- -
-

Revised - - -

-

© Copyright Housemarque Oy 2002

- -

Permission to copy, use, modify, sell and distribute this document is granted -provided this copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with no claim as to its suitability -for any purpose.

- - diff --git a/example/array_arithmetic.c b/example/array_arithmetic.c deleted file mode 100644 index 9f5f3cb..0000000 --- a/example/array_arithmetic.c +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -/* This example implements over 2200 functions for 1-dimensional arithmetic - * array manipulation in C. The idea is to use preprocessor data structures, - * lists and tuples, for storing metainformation to be used for generating - * the actual C code. - * - * Who needs templates anyway? :) - * - * Compile with any C compiler with a standards conforming preprocessor. - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* Information about C operators. */ - -/* Accessors for the operator datatype. */ -#define OP_SYMBOL(O) BOOST_PP_TUPLE_ELEM(5,0,O) -#define OP_NAME(O) BOOST_PP_TUPLE_ELEM(5,1,O) -#define OP_IS_FLOATING(O) BOOST_PP_TUPLE_ELEM(5,2,O) -#define OP_IS_LOGICAL(O) BOOST_PP_TUPLE_ELEM(5,3,O) -#define OP_IS_SHIFT(O) BOOST_PP_TUPLE_ELEM(5,4,O) - -/* List of applicative unary operators. */ -#define APPLICATIVE_UNARY_OPS\ - BOOST_PP_TUPLE_TO_LIST\ - ( 3\ - , ( ( ! , logical_not , 1 , 1 , 0 )\ - , ( ~ , bitwise_not , 0 , 0 , 0 )\ - , ( - , neg , 1 , 0 , 0 )\ - )\ - ) - -/* List of applicative binary operators. */ -#define APPLICATIVE_BINARY_OPS\ - BOOST_PP_TUPLE_TO_LIST\ - ( 18\ - , ( ( * , mul , 1 , 0 , 0 )\ - , ( / , div , 1 , 0 , 0 )\ - , ( % , mod , 0 , 0 , 0 )\ - , ( + , add , 1 , 0 , 0 )\ - , ( - , sub , 1 , 0 , 0 )\ - , ( << , shift_left , 0 , 0 , 1 )\ - , ( >> , shift_right , 0 , 0 , 1 )\ - , ( < , less , 1 , 1 , 0 )\ - , ( <= , less_equal , 1 , 1 , 0 )\ - , ( >= , greater_equal , 1 , 1 , 0 )\ - , ( > , greater , 1 , 1 , 0 )\ - , ( == , equal , 1 , 1 , 0 )\ - , ( != , not_equal , 1 , 1 , 0 )\ - , ( & , bitwise_and , 0 , 0 , 0 )\ - , ( | , bitwise_or , 0 , 0 , 0 )\ - , ( ^ , bitwise_xor , 0 , 0 , 0 )\ - , ( && , logical_and , 1 , 1 , 0 )\ - , ( || , logical_or , 1 , 1 , 0 )\ - )\ - ) - -/* Information about C built-in types. */ - -/* Accessors for the type datatype. */ -#define TYPE_NAME(T) BOOST_PP_TUPLE_ELEM(4,0,T) -#define TYPE_ABBREVIATION(T) BOOST_PP_TUPLE_ELEM(4,1,T) -#define TYPE_IS_FLOATING(T) BOOST_PP_TUPLE_ELEM(4,2,T) -#define TYPE_RANK(T) BOOST_PP_TUPLE_ELEM(4,3,T) - -/* List of C built-in types. */ -#define BUILTIN_TYPES\ - BOOST_PP_TUPLE_TO_LIST\ - ( 12\ - , ( ( signed char , sc , 0 , 1 )\ - , ( char , ch , 0 , 1 )\ - , ( unsigned char , uc , 0 , 1 )\ - , ( short , ss , 0 , 2 )\ - , ( unsigned short , us , 0 , 2 )\ - , TYPE_INT\ - , ( unsigned , ui , 0 , 4 )\ - , ( long , sl , 0 , 5 )\ - , ( unsigned long , ul , 0 , 6 )\ - , ( float , fl , 1 , 7 )\ - , ( double , db , 1 , 8 )\ - , ( long double , ld , 1 , 9 )\ - )\ - ) - -/* Type int is needed in some type computations. */ -#define TYPE_INT ( int , si , 0 , 3 ) - -/* Type computation macros. */ -#define TYPE_OF_INTEGER_PROMOTION(T) BOOST_PP_IF(BOOST_PP_LESS(TYPE_RANK(T),TYPE_RANK(TYPE_INT)),TYPE_INT,T) -#define TYPE_OF_USUAL_ARITHMETIC_CONVERSION(L,R) TYPE_OF_INTEGER_PROMOTION(BOOST_PP_IF(BOOST_PP_LESS(TYPE_RANK(L),TYPE_RANK(R)),R,L)) -#define TYPE_OF_UNARY_OP(O,T) BOOST_PP_IF(OP_IS_LOGICAL(O),TYPE_INT,TYPE_OF_INTEGER_PROMOTION(T)) -#define TYPE_OF_BINARY_OP(O,L,R) BOOST_PP_IF(OP_IS_LOGICAL(O),TYPE_INT,BOOST_PP_IF(OP_IS_SHIFT(O),TYPE_OF_INTEGER_PROMOTION(L),TYPE_OF_USUAL_ARITHMETIC_CONVERSION(L,R))) -#define IS_VALID_UNARY_OP_AND_TYPE_COMBINATION(O,T) BOOST_PP_IF(TYPE_IS_FLOATING(T),OP_IS_FLOATING(O),1) -#define IS_VALID_BINARY_OP_AND_TYPE_COMBINATION(O,L,R) BOOST_PP_IF(BOOST_PP_OR(TYPE_IS_FLOATING(L),TYPE_IS_FLOATING(R)),OP_IS_FLOATING(O),1) - -/* Generates code for all all unary operators and integral types. */ -#define UNARY_ARRAY_OP(_,OT) BOOST_PP_IF(IS_VALID_UNARY_OP_AND_TYPE_COMBINATION OT,UNARY_ARRAY_OP_CODE,BOOST_PP_TUPLE2_EAT) OT -#define UNARY_ARRAY_OP_CODE(O,T)\ - void BOOST_PP_LIST_CAT(BOOST_PP_TUPLE_TO_LIST(4,(array_,OP_NAME(O),_,TYPE_ABBREVIATION(T))))\ - ( const TYPE_NAME(T)* in\ - , TYPE_NAME(TYPE_OF_UNARY_OP(O,T))* out\ - , unsigned n\ - )\ - { do\ - { *out++ = OP_SYMBOL(O) *in++;\ - } while (--n);\ - } - -BOOST_PP_LIST_FOR_EACH_PRODUCT(UNARY_ARRAY_OP,2,(APPLICATIVE_UNARY_OPS,BUILTIN_TYPES)) - -/* Generates code for all binary operators and integral type pairs. */ -#define BINARY_ARRAY_OP(_,OLR) BOOST_PP_IF(IS_VALID_BINARY_OP_AND_TYPE_COMBINATION OLR,BINARY_ARRAY_OP_CODE,BOOST_PP_TUPLE3_EAT) OLR -#define BINARY_ARRAY_OP_CODE(O,L,R)\ - void BOOST_PP_LIST_CAT(BOOST_PP_TUPLE_TO_LIST(6,(array_,OP_NAME(O),_,TYPE_ABBREVIATION(L),_,TYPE_ABBREVIATION(R))))\ - ( const TYPE_NAME(L)* lhs_in\ - , const TYPE_NAME(R)* rhs_in\ - , TYPE_NAME(TYPE_OF_BINARY_OP(O,L,R))* out\ - , unsigned n\ - )\ - { do\ - { *out++ = *lhs_in OP_SYMBOL(O) *rhs_in;\ - ++lhs_in;\ - ++rhs_in;\ - } while (--n);\ - } - -BOOST_PP_LIST_FOR_EACH_PRODUCT(BINARY_ARRAY_OP,3,(APPLICATIVE_BINARY_OPS,BUILTIN_TYPES,BUILTIN_TYPES)) diff --git a/example/catch_builtin.cpp b/example/catch_builtin.cpp deleted file mode 100644 index 852c3a1..0000000 --- a/example/catch_builtin.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -/* This example demonstrates the usage of lists and BOOST_PP_LIST_FOR_EACH(). */ - -#include -#include -#include -#include - -/* List of built-in types. (Strictly speaking wchar_t should be on the list.) */ -#define BUILTIN_TYPES\ - BOOST_PP_TUPLE_TO_LIST\ - ( 13\ - , ( bool\ - , char\ - , signed char\ - , unsigned char\ - , unsigned short\ - , short\ - , int\ - , unsigned\ - , long\ - , unsigned long\ - , float\ - , double\ - , long double\ - )\ - ) - -/* This is the macro we pass to BOOST_PP_LIST_FOR_EACH(). */ -#define CATCH(R,_,T)\ - catch (T t) { std::cerr << "Caught an " << typeid(t).name() << " = " << t; } - -int main() -{ - try { throw 10; } - BOOST_PP_LIST_FOR_EACH(CATCH,_,BUILTIN_TYPES) - - return 0; -} diff --git a/example/count_down.c b/example/count_down.c deleted file mode 100644 index e9162d0..0000000 --- a/example/count_down.c +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -/* This is a trivial example of using BOOST_PP_WHILE() that simply - * counts down from N to 0 ultimately expanding to a 0. - */ - -#include -#include - -#define COUNT_DOWN(N) BOOST_PP_WHILE(COUNT_DOWN_C,COUNT_DOWN_F,N) -/* Above is the macro we are implementing using BOOST_PP_WHILE(). */ - -#define COUNT_DOWN_C(D,N) N -/* Above is the condition. It expands to the current N. */ - -#define COUNT_DOWN_F(D,N) BOOST_PP_DEC(N) -/* Above is the iteration macro. It decrements N. */ - -enum { x = COUNT_DOWN(50) }; -/* The above expands to 0. */ diff --git a/example/delay.c b/example/delay.c deleted file mode 100644 index 059ca34..0000000 --- a/example/delay.c +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -#include -#include -#include -#include -#include - -/* The time complexity of DELAY(N) is O(pow(2,N)). - * - * Handy when recompiles are too fast to take a coffee break. :) - * - * Template metaprogramming can be used for implementing similar - * delays. Unfortunately template instantiation consumes memory, - * therefore compilers usually fail to fully compile long template - * based delays, because they run out of memory. - * - * On many compilers (e.g. g++, MSVC++), this macro takes only a - * small amount of memory to preprocess. On some compilers (e.g. - * MWCW), however, this macro seems to consume huge amounts of - * memory. - */ - -#ifndef DELAY_MAX -#define DELAY_MAX 14 -#endif - -#define DELAY(N) BOOST_PP_TUPLE_ELEM(2,0,(BOOST_PP_EMPTY,BOOST_PP_WHILE(DELAY_C,BOOST_PP_CAT(DELAY_F,N),BOOST_PP_DEC(N))))() -#define DELAY_C(D,N) N -#define DELAY_F0(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F1(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F2(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F3(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F4(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F5(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F6(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F7(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F8(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F9(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F10(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F11(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F12(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F13(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F14(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F15(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F16(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F17(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F18(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F19(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F20(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F21(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F22(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F23(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F24(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F25(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F26(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F27(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F28(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F29(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F30(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F31(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F32(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F33(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F34(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F35(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F36(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F37(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F38(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F39(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F40(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F41(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F42(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F43(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F44(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F45(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F46(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F47(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F48(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F49(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) -#define DELAY_F50(D,N) BOOST_PP_IF(1,BOOST_PP_DEC(N),BOOST_PP_WHILE##D(DELAY_C,DELAY_F##N,BOOST_PP_DEC(N))) - -DELAY(DELAY_MAX) diff --git a/example/duffs_device.c b/example/duffs_device.c deleted file mode 100644 index e06e490..0000000 --- a/example/duffs_device.c +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -/* This example uses the preprocessor library to implement a generalized - * macro for implementing a Duff's Device. - * - * This example was inspired by an original generalized macro for - * implementing Duff's Device written by Joerg Walter. - */ - -#include -#include -#include - -/* Expands to a Duff's Device. */ -#define DUFFS_DEVICE(UNROLLING_FACTOR,COUNTER_TYPE,N,STATEMENT)\ - do\ - {\ - COUNTER_TYPE duffs_device_initial_cnt = (N);\ - if (duffs_device_initial_cnt > 0)\ - {\ - COUNTER_TYPE duffs_device_running_cnt = (duffs_device_initial_cnt + (UNROLLING_FACTOR-1))/UNROLLING_FACTOR;\ - switch (duffs_device_initial_cnt % UNROLLING_FACTOR)\ - {\ - do\ - {\ - BOOST_PP_REPEAT(UNROLLING_FACTOR,DUFFS_DEVICE_C,(UNROLLING_FACTOR,{STATEMENT}))\ - } while (--duffs_device_running_cnt);\ - }\ - }\ - } while (0) - -#define DUFFS_DEVICE_C(I,UNROLLING_FACTOR_STATEMENT)\ - case (I?BOOST_PP_TUPLE_ELEM(2,0,UNROLLING_FACTOR_STATEMENT)-I:0): BOOST_PP_TUPLE_ELEM(2,1,UNROLLING_FACTOR_STATEMENT); - - -#ifndef UNROLLING_FACTOR -#define UNROLLING_FACTOR 16 -#endif - -#ifndef N -#define N 1000 -#endif - -int main(void) -{ - int i=0; - DUFFS_DEVICE(UNROLLING_FACTOR, int, 0, ++i;); - assert(i == 0); - DUFFS_DEVICE(UNROLLING_FACTOR, int, N, ++i;); - assert(i == N); - - return 0; -} diff --git a/example/is_integral.cpp b/example/is_integral.cpp deleted file mode 100644 index 95541df..0000000 --- a/example/is_integral.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -/* This example demonstrates the usage of preprocessor lists for generating C++ code. */ - -#include -#include -#include -#include - -/* List of integral types. (Strictly speaking, wchar_t should be on the list.) */ -#define INTEGRAL_TYPES\ - BOOST_PP_TUPLE_TO_LIST(9,(char, signed char, unsigned char, short, unsigned short, int, unsigned, long, unsigned long)) - -/* List of invokeable cv-qualifiers. */ -#define CV_QUALIFIERS\ - BOOST_PP_TUPLE_TO_LIST(4,(BOOST_PP_EMPTY, const BOOST_PP_EMPTY, volatile BOOST_PP_EMPTY, const volatile BOOST_PP_EMPTY)) - -/* Template for testing whether a type is an integral type. */ -template struct is_integral {enum {value = false};}; - -/* Macro for defining a specialization of is_integral<> template. */ -#define IS_INTEGRAL_SPECIALIZATION(R,L)\ - template<> struct is_integral {enum {value = true};}; - -BOOST_PP_LIST_FOR_EACH_PRODUCT(IS_INTEGRAL_SPECIALIZATION,2,(CV_QUALIFIERS, INTEGRAL_TYPES)) -#undef IS_INTEGRAL_SPECIALIZATION -#undef CV_QUALIFIERS -#undef INTEGRAL_TYPES diff --git a/example/linear_fib.c b/example/linear_fib.c deleted file mode 100644 index bd3d8f3..0000000 --- a/example/linear_fib.c +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -/* This example shows how BOOST_PP_WHILE() can be used for implementing - * macros. - */ - -#include -#include -#include -#include -#include -#include - -/* First consider the following C implementation of Fibonacci. */ - -typedef struct linear_fib_state { int a0, a1, n; } linear_fib_state; - -static int linear_fib_c( linear_fib_state p ) -{ - return p.n; -} - -static linear_fib_state linear_fib_f( linear_fib_state p ) -{ - linear_fib_state r = { p.a1, p.a0 + p.a1, p.n - 1 }; - return r; -} - -static int linear_fib( int n ) -{ - linear_fib_state p = { 0, 1, n }; - - while ( linear_fib_c(p) ) { p = linear_fib_f(p); } - - return p.a0; -} - -/* Then consider the following preprocessor implementation of Fibonacci. */ - -#define LINEAR_FIB(N)\ - LINEAR_FIB_D(0,N) -/* Since the macro is implemented using BOOST_PP_WHILE, the actual - * implementation takes a depth as a parameter so that it can be called - * inside a BOOST_PP_WHILE. The above easy-to-use version simply uses 0 - * as the depth and can not be called inside a BOOST_PP_WHILE. - */ - -#define LINEAR_FIB_D(D,N)\ - BOOST_PP_TUPLE_ELEM(3,0,BOOST_PP_WHILE##D(LINEAR_FIB_C,LINEAR_FIB_F,(0,1,N))) -/* ^^^ ^^^ ^^ ^^ ^^^^^^^ - * #1 #2 #3 #3 #1 - * - * #1) The state is a 3-tuple. After the iteration is finished, the first - * element of the tuple is the result. - * - * #2) The WHILE primitive is "invoked" directly. BOOST_PP_WHILE(D,...) - * can't be used because it would not be expanded by the C++ preprocessor. - * - * #3) ???_C is the condition and ???_F is the iteration macro. - */ - -#define LINEAR_FIB_C(D,P)\ - /* p.n */ BOOST_PP_TUPLE_ELEM(3,2,P) - -#define LINEAR_FIB_F(D,P)\ - (/* p.a1 */ BOOST_PP_TUPLE_ELEM(3,1,P)\ - ,/* p.a0+p.a1*/ BOOST_PP_ADD_D(D,BOOST_PP_TUPLE_ELEM(3,0,P),BOOST_PP_TUPLE_ELEM(3,1,P))\ - /* ^^ ^ \ - * BOOST_PP_ADD() uses BOOST_PP_WHILE(). Therefore we must\ - * pass the recursion depth explicitly to BOOST_PP_ADD_D().\ - */\ - ,/* p.n - 1 */ BOOST_PP_DEC(BOOST_PP_TUPLE_ELEM(3,2,P))\ - ) - -int main() -{ - printf("linear_fib(10) = %d\n", linear_fib(10)); - printf("LINEAR_FIB(10) = %d\n", LINEAR_FIB(10)); - - return 0; -} diff --git a/example/note.c b/example/note.c deleted file mode 100644 index e4d34a4..0000000 --- a/example/note.c +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -/* This example shows how BOOST_PP_STRINGIZE() can be used to allow macro - * expansion before stringization. - */ - -#include - -#define NOTE(STR)\ - message(__FILE__ "(" BOOST_PP_STRINGIZE(__LINE__) ") : " STR) - -#pragma NOTE("Hello, World!") diff --git a/example/repeat_2d.c b/example/repeat_2d.c deleted file mode 100644 index ebfd5c7..0000000 --- a/example/repeat_2d.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -/* This example implements a generalized macro for 2D repetition using - * the simple repetition primitives of the preprocessor library. - */ - -#include - -/**

Repeats the macro M(X,Y,DATA) for X = [0,W) and Y = [0,H).

- -

In other words, expands to the sequence:

- -
-M(  0,  0,  DATA) M(  1,  0,  DATA) ... M(W-1,  0,  DATA)
-M(  0,  1,  DATA) M(  1,  1,  DATA) ... M(W-1,  1,  DATA)
-      ...            ...      ...       ...
-M(  0,H-1,  DATA) M(  1,H-1,  DATA) ... M(W-1,H-1,  DATA)
-
-*/ -#define REPEAT_2D(W,H,M,DATA)\ - /* Here we can simply use BOOST_PP_REPEAT(), because\ - * it implements automatic recursion.\ - */\ - BOOST_PP_REPEAT\ - ( H\ - , REPEAT_2D_ROW\ - , (W,M,DATA)\ - ) - -#define REPEAT_2D_ROW(Y,WMD)\ - BOOST_PP_REPEAT\ - ( BOOST_PP_TUPLE_ELEM(3,0,WMD)\ - , REPEAT_2D_ELEM\ - , (Y, BOOST_PP_TUPLE_ELEM(3,1,WMD), BOOST_PP_TUPLE_ELEM(3,2,WMD))\ - ) -#define REPEAT_2D_ELEM(X,YMD)\ - BOOST_PP_TUPLE_ELEM(3,1,YMD)\ - ( X\ - , BOOST_PP_TUPLE_ELEM(3,0,YMD)\ - , BOOST_PP_TUPLE_ELEM(3,2,YMD)\ - ) - -#include -#include -#include -#include - -/* Here we use the above macro to generate something. */ -#define ELEM(X,Y,E) BOOST_PP_COMMA_IF(BOOST_PP_OR(X,Y)) BOOST_PP_LIST_CAT(BOOST_PP_TUPLE_TO_LIST(5,(E,_,X,_,Y))) - -enum { REPEAT_2D(3,4,ELEM,elem) }; - -/* The above expands to: - * - * enum { elem_0_0, elem_1_0, elem_2_0, - * elem_0_1, elem_1_1, elem_2_1, - * elem_0_2, elem_1_2, elem_2_2, - * elem_0_3, elem_1_3, elem_2_3 }; - */ diff --git a/example/static_assert.c b/example/static_assert.c deleted file mode 100644 index 88d192f..0000000 --- a/example/static_assert.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -/* This example shows how BOOST_PP_CAT() can be used to allow macro - * expansion before token concatenation. - */ - -#include - -/* Use of BOOST_PP_CAT() below allows macro expansion of __LINE__. */ -#define STATIC_ASSERT(EXPR)\ - typedef char BOOST_PP_CAT(static_assert_,__LINE__)[ (EXPR) ? 1 : -1 ] - -STATIC_ASSERT(sizeof(int) <= sizeof(long)); - -/* This static assert is broken. The __LINE__ is not expanded as desired. */ -#define BROKEN_STATIC_ASSERT(EXPR)\ - typedef char static_assert_##__LINE__[ (EXPR) ? 1 : -1 ] - -BROKEN_STATIC_ASSERT(sizeof(int) <= sizeof(long)); diff --git a/example/subscript_layer.cpp b/example/subscript_layer.cpp deleted file mode 100644 index 83149fa..0000000 --- a/example/subscript_layer.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (C) 2002 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -/* This example shows how BOOST_PP_EMPTY can be used as an unused or - * empty parameter. - */ - -#include - -/* This could be a layer from a generative container library. */ -template -struct subscript_layer : base -{ -#define DEF(CV)\ - CV() typename base::value_type& operator[](typename base::index_type i) CV()\ - { return base::begin()[i]; } - - DEF(BOOST_PP_EMPTY) - DEF(const BOOST_PP_EMPTY) -#undef DEF -}; diff --git a/regression/arithmetic.cpp b/regression/arithmetic.cpp deleted file mode 100644 index 6d3cf31..0000000 --- a/regression/arithmetic.cpp +++ /dev/null @@ -1,63 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include -# include - -// addition - -BEGIN BOOST_PP_ADD(2, 3) == 5 END - -BEGIN BOOST_PP_ADD(BOOST_PP_ADD(2, 2), 2) == 6 END -BEGIN BOOST_PP_ADD(2, BOOST_PP_ADD(1, 4)) == 7 END -BEGIN BOOST_PP_ADD(BOOST_PP_ADD(2, 2), BOOST_PP_ADD(2, 2)) == 8 END - -// subtraction - -BEGIN BOOST_PP_SUB(11, 0) == 11 END -BEGIN BOOST_PP_SUB(12, 1) == 11 END -BEGIN BOOST_PP_SUB(3, 4) == 0 END - -BEGIN BOOST_PP_SUB(5, BOOST_PP_SUB(3, 2)) == 4 END -BEGIN BOOST_PP_SUB(BOOST_PP_SUB(10, 5), 2) == 3 END -BEGIN BOOST_PP_SUB(BOOST_PP_SUB(7, 3), BOOST_PP_SUB(10, 8)) == 2 END - -// multiplication - -BEGIN BOOST_PP_MUL(0, 1) == 0 END -BEGIN BOOST_PP_MUL(1, 0) == 0 END -BEGIN BOOST_PP_MUL(1, 1) == 1 END -BEGIN BOOST_PP_MUL(4, 3) == 12 END - -BEGIN BOOST_PP_MUL(BOOST_PP_MUL(2, 2), 2) == 8 END -BEGIN BOOST_PP_MUL(2, BOOST_PP_MUL(2, 2)) == 8 END -BEGIN BOOST_PP_MUL(BOOST_PP_MUL(2, 2), BOOST_PP_MUL(2, 2)) == 16 END - -// division - -BEGIN BOOST_PP_DIV(2, 1) == 2 END -BEGIN BOOST_PP_DIV(0, 5) == 0 END -BEGIN BOOST_PP_DIV(7, 3) == 2 END - -BEGIN BOOST_PP_DIV(BOOST_PP_DIV(4, 2), 2) == 1 END -BEGIN BOOST_PP_DIV(10, BOOST_PP_DIV(10, 2)) == 2 END -BEGIN BOOST_PP_DIV(BOOST_PP_DIV(10, 2), BOOST_PP_DIV(4, 2)) == 2 END - -// modulus - -BEGIN BOOST_PP_MOD(5, 5) == 0 END -BEGIN BOOST_PP_MOD(9, 5) == 4 END -BEGIN BOOST_PP_MOD(7, 4) == 3 END - -BEGIN BOOST_PP_MOD(BOOST_PP_MOD(5, 3), 3) == 2 END -BEGIN BOOST_PP_MOD(5, BOOST_PP_MOD(4, 3)) == 0 END diff --git a/regression/array.cpp b/regression/array.cpp deleted file mode 100644 index a093c76..0000000 --- a/regression/array.cpp +++ /dev/null @@ -1,26 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include - -# define ARRAY (3, (0, 1, 2)) - -// element access - -BEGIN BOOST_PP_ARRAY_ELEM(1, ARRAY) == 1 END -BEGIN BOOST_PP_ARRAY_ELEM(2, (5, (0, 1, 2, 3, 4))) == 2 END - -// size - -BEGIN BOOST_PP_ARRAY_SIZE(ARRAY) == 3 END -BEGIN BOOST_PP_ARRAY_SIZE((5, (0, 1, 2, 3, 4))) == 5 END diff --git a/regression/comparison.cpp b/regression/comparison.cpp deleted file mode 100644 index a8cd002..0000000 --- a/regression/comparison.cpp +++ /dev/null @@ -1,46 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include - -// equality - -BEGIN BOOST_PP_EQUAL(2, 0) == 0 END -BEGIN BOOST_PP_EQUAL(2, 2) == 1 END - -// inequality - -BEGIN BOOST_PP_NOT_EQUAL(2, 0) == 1 END -BEGIN BOOST_PP_NOT_EQUAL(2, 2) == 0 END - -// less - -BEGIN BOOST_PP_LESS(2, 1) == 0 END -BEGIN BOOST_PP_LESS(1, 2) == 1 END - -// less_equal - -BEGIN BOOST_PP_LESS_EQUAL(2, 1) == 0 END -BEGIN BOOST_PP_LESS_EQUAL(1, 2) == 1 END -BEGIN BOOST_PP_LESS_EQUAL(2, 2) == 1 END - -// greater - -BEGIN BOOST_PP_GREATER(2, 1) == 1 END -BEGIN BOOST_PP_GREATER(1, 2) == 0 END - -// greater_equal - -BEGIN BOOST_PP_GREATER_EQUAL(2, 1) == 1 END -BEGIN BOOST_PP_GREATER_EQUAL(1, 2) == 0 END -BEGIN BOOST_PP_GREATER_EQUAL(2, 2) == 1 END diff --git a/regression/control.cpp b/regression/control.cpp deleted file mode 100644 index ffa54a8..0000000 --- a/regression/control.cpp +++ /dev/null @@ -1,41 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include -# include -# include - -# define TR(x) 1 - -BEGIN BOOST_PP_EXPR_IIF(0, TR)(0) == 0 END -BEGIN BOOST_PP_EXPR_IIF(1, TR)(0) == 1 END - -BEGIN BOOST_PP_EXPR_IF(3, TR)(0) == 1 END -BEGIN BOOST_PP_EXPR_IF(0, TR)(0) == 0 END - -BEGIN BOOST_PP_IIF(0, 1, 0) == 0 END -BEGIN BOOST_PP_IIF(1, 1, 0) == 1 END - -BEGIN BOOST_PP_IF(0, 1, 0) == 0 END -BEGIN BOOST_PP_IF(9, 1, 0) == 1 END - -# define PRED(d, state) state -# define OP_1(d, state) BOOST_PP_DEC(state) - -BEGIN BOOST_PP_WHILE(PRED, OP_1, 50) == 0 END - -# define OP_2(d, state) BOOST_PP_DEC(BOOST_PP_ADD(BOOST_PP_WHILE(PRED, OP_1, state), state)) -# define OP_3(d, state) BOOST_PP_DEC(BOOST_PP_ADD_D(d, BOOST_PP_WHILE_ ## d(PRED, OP_1, state), state)) - -BEGIN BOOST_PP_WHILE(PRED, OP_3, 10) == 0 END -BEGIN BOOST_PP_WHILE(PRED, OP_3, 10) == 0 END diff --git a/regression/debug.cpp b/regression/debug.cpp deleted file mode 100644 index d4094bf..0000000 --- a/regression/debug.cpp +++ /dev/null @@ -1,22 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include - -BEGIN sizeof(BOOST_PP_ASSERT_MSG(0, "text") "") / sizeof(char) != 1 END -BEGIN sizeof(BOOST_PP_ASSERT_MSG(1, "text") "") / sizeof(char) == 1 END - -BOOST_PP_ASSERT(10) - -# line BOOST_PP_LINE(100, __FILE__) -BEGIN __LINE__ == 100 END diff --git a/regression/facilities.cpp b/regression/facilities.cpp deleted file mode 100644 index 9a8f3e6..0000000 --- a/regression/facilities.cpp +++ /dev/null @@ -1,29 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include -# include - -BEGIN BOOST_PP_APPLY(BOOST_PP_NIL) 0 == 0 END -BEGIN BOOST_PP_APPLY((0)) == 0 END - -BEGIN BOOST_PP_APPLY((BOOST_PP_EMPTY))() 0 == 0 END - -# define MACRO(x, y, z) 1 -# define ARGS (1, 2, 3) - -BEGIN BOOST_PP_EXPAND(MACRO ARGS) == 1 END - -BEGIN BOOST_PP_IDENTITY(1)() == 1 END - -BEGIN BOOST_PP_CAT(BOOST_PP_INTERCEPT, 2) 1 == 1 END diff --git a/regression/iteration.cpp b/regression/iteration.cpp deleted file mode 100644 index d7d7949..0000000 --- a/regression/iteration.cpp +++ /dev/null @@ -1,34 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# if !BOOST_PP_IS_SELFISH -# -# include -# -# define TEST(n) BEGIN n == n END -# -# define BOOST_PP_LOCAL_MACRO(n) TEST(n) -# define BOOST_PP_LOCAL_LIMITS (1, 5) -# include BOOST_PP_LOCAL_ITERATE() -# -# define BOOST_PP_LOCAL_MACRO(n) TEST(n) -# define BOOST_PP_LOCAL_LIMITS (5, 1) -# include BOOST_PP_LOCAL_ITERATE() -# -# define BOOST_PP_INDIRECT_SELF -# include BOOST_PP_INCLUDE_SELF() -# -# else - -BEGIN BOOST_PP_IS_SELFISH == 1 END - -# endif diff --git a/regression/iteration.h b/regression/iteration.h deleted file mode 100644 index 072ab7e..0000000 --- a/regression/iteration.h +++ /dev/null @@ -1,61 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# if !BOOST_PP_IS_ITERATING -# -# include -# include -# include -# -# define NO_FLAGS -# -# define BOOST_PP_ITERATION_PARAMS_1 (3, (1, 10, )) -# include BOOST_PP_ITERATE() -# -# undef NO_FLAGS -# -# define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 5, , 0x0001)) -# include BOOST_PP_ITERATE() -# -# define BOOST_PP_ITERATION_PARAMS_1 (4, (1, 5, , 0x0002)) -# include BOOST_PP_ITERATE() -# -# elif defined NO_FLAGS - -struct BOOST_PP_CAT(X, BOOST_PP_ITERATION()) { - BEGIN - BOOST_PP_ITERATION() >= BOOST_PP_ITERATION_START() && - BOOST_PP_ITERATION() <= BOOST_PP_ITERATION_FINISH() - END -}; - -# elif BOOST_PP_ITERATION_DEPTH() == 1 \ - && BOOST_PP_ITERATION_FLAGS() == 0x0001 - -struct BOOST_PP_CAT(Y, BOOST_PP_ITERATION()) { }; - -# elif BOOST_PP_ITERATION_DEPTH() == 1 \ - && BOOST_PP_ITERATION_FLAGS() == 0x0002 - -# define BOOST_PP_ITERATION_PARAMS_2 (3, (1, BOOST_PP_ITERATION(), )) -# include BOOST_PP_ITERATE() - -# elif BOOST_PP_ITERATION_DEPTH() == 2 \ - && BOOST_PP_FRAME_FLAGS(1) == 0x0002 - -struct BOOST_PP_CAT(Z, BOOST_PP_CAT(BOOST_PP_ITERATION(), BOOST_PP_RELATIVE_ITERATION(1))) { }; - -# else -# -# error should not get here! -# -# endif diff --git a/regression/list.cpp b/regression/list.cpp deleted file mode 100644 index 7e84f5a..0000000 --- a/regression/list.cpp +++ /dev/null @@ -1,55 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include -# include -# include -# include -# include - -# define LIST (4, (1, (5, (2, BOOST_PP_NIL)))) - -# define REVERSAL(d, x, y) BOOST_PP_SUB_D(d, y, x) - -BEGIN BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_SUB_D, 22, LIST) == 10 END -BEGIN BOOST_PP_LIST_FOLD_RIGHT(BOOST_PP_ADD_D, 0, LIST) == 12 END -BEGIN BOOST_PP_LIST_FOLD_RIGHT(REVERSAL, 0, LIST) == 4 END - -BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_REVERSE(LIST)) == 2514 END - -BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_REST_N(2, LIST)) == 52 END -BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FIRST_N(2, LIST)) == 41 END - -BEGIN BOOST_PP_LIST_AT(LIST, 2) == 5 END -BEGIN BOOST_PP_LIST_SIZE(LIST) == 4 END - -BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_TRANSFORM(BOOST_PP_ADD_D, 2, LIST)) == 6374 END -BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_APPEND(BOOST_PP_LIST_REST(LIST), LIST)) == 1524152 END - -# define F1(r, state, x) + x + state -BEGIN BOOST_PP_LIST_FOR_EACH(F1, 1, LIST) == 16 END - -BEGIN BOOST_PP_TUPLE_ELEM(4, 3, BOOST_PP_LIST_TO_TUPLE(LIST)) == 2 END - -BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FILTER(BOOST_PP_LESS_D, 3, LIST)) == 45 END - -# define F2(r, x) + BOOST_PP_TUPLE_ELEM(2, 0, x) + 2 - BOOST_PP_TUPLE_ELEM(2, 1, x) -BEGIN BOOST_PP_LIST_FOR_EACH_PRODUCT(F2, 2, ( (1, (0, BOOST_PP_NIL)), (2, (3, BOOST_PP_NIL)) )) == 0 END - -# define L1 (0, (x, BOOST_PP_NIL)) -# define L2 (a, (1, (b, (2, BOOST_PP_NIL)))) -# define L3 (c, (3, (d, BOOST_PP_NIL))) - -# define LL (L1, (L2, (L3, BOOST_PP_NIL))) - -BEGIN BOOST_PP_LIST_CAT(BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_LIST_APPEND_D, BOOST_PP_NIL, LL)) == 0x0a1b2c3d END diff --git a/regression/logical.cpp b/regression/logical.cpp deleted file mode 100644 index 178aa1b..0000000 --- a/regression/logical.cpp +++ /dev/null @@ -1,37 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include - -BEGIN BOOST_PP_NOT(0) == 1 END -BEGIN BOOST_PP_NOT(2) == 0 END - -BEGIN BOOST_PP_AND(0, 0) == 0 END -BEGIN BOOST_PP_AND(0, 3) == 0 END -BEGIN BOOST_PP_AND(4, 0) == 0 END -BEGIN BOOST_PP_AND(5, 6) == 1 END - -BEGIN BOOST_PP_OR(0, 0) == 0 END -BEGIN BOOST_PP_OR(0, 7) == 1 END -BEGIN BOOST_PP_OR(8, 0) == 1 END -BEGIN BOOST_PP_OR(9, 1) == 1 END - -BEGIN BOOST_PP_XOR(0, 0) == 0 END -BEGIN BOOST_PP_XOR(0, 2) == 1 END -BEGIN BOOST_PP_XOR(3, 0) == 1 END -BEGIN BOOST_PP_XOR(4, 5) == 0 END - -BEGIN BOOST_PP_NOR(0, 0) == 1 END -BEGIN BOOST_PP_NOR(0, 6) == 0 END -BEGIN BOOST_PP_NOR(7, 0) == 0 END -BEGIN BOOST_PP_NOR(8, 9) == 0 END diff --git a/regression/repetition.cpp b/regression/repetition.cpp deleted file mode 100644 index cde9a4c..0000000 --- a/regression/repetition.cpp +++ /dev/null @@ -1,51 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include -# include -# include -# include -# include -# include - -# define MAX 10 - -# define NTH(z, n, data) data ## n - -int add(BOOST_PP_ENUM_PARAMS(MAX, int x)) { - return BOOST_PP_REPEAT(MAX, NTH, + x); -} - -const int r = add(BOOST_PP_ENUM_PARAMS(MAX, 1 BOOST_PP_INTERCEPT)); - -# define CONSTANT(z, n, text) BOOST_PP_CAT(text, n) = n -const int BOOST_PP_ENUM(MAX, CONSTANT, default_param_); - -# define TEST(n) \ - void BOOST_PP_CAT(test_enum_params, n)(BOOST_PP_ENUM_PARAMS(n, int x)); \ - void BOOST_PP_CAT(test_enum_params_with_a_default, n)(BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(n, int x, 0)); \ - void BOOST_PP_CAT(test_enum_params_with_defaults, n)(BOOST_PP_ENUM_PARAMS_WITH_DEFAULTS(n, int x, default_param_)); - -TEST(0) -TEST(MAX) - -template struct no_rescan; - -# define F1(z, n, p) p n -BEGIN 1 + (4+5+6) BOOST_PP_REPEAT_FROM_TO(4, 7, F1, -) END - -# define PRED(r, state) BOOST_PP_NOT_EQUAL(state, BOOST_PP_INC(MAX)) -# define OP(r, state) BOOST_PP_INC(state) -# define MACRO(r, state) BOOST_PP_COMMA_IF(BOOST_PP_NOT_EQUAL(state, 1)) BOOST_PP_CAT(class T, state) - -template struct for_test; diff --git a/regression/selection.cpp b/regression/selection.cpp deleted file mode 100644 index 3491f72..0000000 --- a/regression/selection.cpp +++ /dev/null @@ -1,22 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include - -BEGIN BOOST_PP_MAX(2, 2) == 2 END -BEGIN BOOST_PP_MAX(2, 1) == 2 END -BEGIN BOOST_PP_MAX(1, 2) == 2 END - -BEGIN BOOST_PP_MIN(2, 2) == 2 END -BEGIN BOOST_PP_MIN(2, 1) == 1 END -BEGIN BOOST_PP_MIN(1, 2) == 1 END diff --git a/regression/slot.cpp b/regression/slot.cpp deleted file mode 100644 index 24047a0..0000000 --- a/regression/slot.cpp +++ /dev/null @@ -1,28 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include - -# define X() 4 - -# define BOOST_PP_VALUE 1 + 2 + 3 + X() -# include BOOST_PP_ASSIGN_SLOT(1) - -# undef X - -BEGIN BOOST_PP_SLOT(1) == 10 END - -# define BOOST_PP_VALUE BOOST_PP_SLOT(1) * BOOST_PP_SLOT(1) -# include BOOST_PP_ASSIGN_SLOT(1) - -BEGIN BOOST_PP_SLOT(1) == 100 END diff --git a/regression/test.h b/regression/test.h deleted file mode 100644 index 71bb657..0000000 --- a/regression/test.h +++ /dev/null @@ -1,33 +0,0 @@ -# /* Copyright (C) 2001 -# * Housemarque Oy -# * http://www.housemarque.com -# * -# * 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. -# */ -# -# /* Revised by Paul Mensonides (2002) */ -# -# /* See http://www.boost.org for most recent version. */ -# -# ifndef BOOST_LIBS_PREPROCESSOR_REGRESSION_TEST_H -# define BOOST_LIBS_PREPROCESSOR_REGRESSION_TEST_H -# -# include -# -# define BEGIN typedef int BOOST_PP_CAT(test_, __LINE__)[(( -# define END )==1) ? 1 : -1]; - -#include - -namespace std { } -using namespace std; - -int main(void) { - printf("pass " __TIME__); - return 0; -} - -# endif diff --git a/regression/tuple.cpp b/regression/tuple.cpp deleted file mode 100644 index 9e1dc8d..0000000 --- a/regression/tuple.cpp +++ /dev/null @@ -1,25 +0,0 @@ -# /* ************************************************************************** -# * * -# * (C) Copyright Paul Mensonides 2002. 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 at to its suitability for any purpose. * -# * * -# ************************************************************************** */ -# -# /* See http://www.boost.org for most recent version. */ -# -# include -# include - -# define TUPLE (0, 1, 2, 3, 4, 5) - -BEGIN BOOST_PP_TUPLE_ELEM(6, 3, TUPLE) == 3 END -BEGIN BOOST_PP_TUPLE_ELEM(6, 5, TUPLE) == 5 END - -# define CALC(x) BOOST_PP_TUPLE_ELEM(3, 0, x) BOOST_PP_TUPLE_ELEM(3, 1, x) BOOST_PP_TUPLE_ELEM(3, 2, x) -# define T2 (+3, /2, +6) - -BEGIN CALC(T2) == 7 END -BEGIN CALC(BOOST_PP_TUPLE_REVERSE(3, T2)) == 6 END diff --git a/test/arithmetic_test.cpp b/test/arithmetic_test.cpp deleted file mode 100644 index 3e9f520..0000000 --- a/test/arithmetic_test.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2001 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -#include -#include -#include -#include -#include - -#include - -/* *** */ - -TEST_B BOOST_PP_ADD(2,3) == 5 TEST_E -TEST_B BOOST_PP_ADD(21,BOOST_PP_SUB(BOOST_PP_LIMIT_MAG,20)) == BOOST_PP_LIMIT_MAG TEST_E - -TEST_B BOOST_PP_SUB(11,0) == 11 TEST_E -TEST_B BOOST_PP_SUB(12,1) == 11 TEST_E -TEST_B BOOST_PP_SUB(3,4) == 0 TEST_E - -TEST_B BOOST_PP_MUL(0,1) == 0 TEST_E -TEST_B BOOST_PP_MUL(1,0) == 0 TEST_E -TEST_B BOOST_PP_MUL(1,1) == 1 TEST_E -TEST_B BOOST_PP_MUL(4,3) == 12 TEST_E - -TEST_B BOOST_PP_DIV(2,1) == 2 TEST_E -TEST_B BOOST_PP_DIV(0,5) == 0 TEST_E -TEST_B BOOST_PP_DIV(7,3) == 2 TEST_E - -TEST_B BOOST_PP_EQUAL(1,0) == 0 TEST_E -TEST_B BOOST_PP_EQUAL(10,10) == 1 TEST_E - -TEST_B BOOST_PP_NOT_EQUAL(3,4) == 1 TEST_E -TEST_B BOOST_PP_NOT_EQUAL(7,7) == 0 TEST_E - -TEST_B BOOST_PP_LESS_EQUAL(6,7) == 1 TEST_E -TEST_B BOOST_PP_LESS_EQUAL(8,1) == 0 TEST_E -TEST_B BOOST_PP_LESS_EQUAL(5,5) == 1 TEST_E - -TEST_B BOOST_PP_GREATER_EQUAL(6,7) == 0 TEST_E -TEST_B BOOST_PP_GREATER_EQUAL(10,10) == 1 TEST_E -TEST_B BOOST_PP_GREATER_EQUAL(8,1) == 1 TEST_E - -TEST_B BOOST_PP_LESS(2,1) == 0 TEST_E -TEST_B BOOST_PP_LESS(1,1) == 0 TEST_E -TEST_B BOOST_PP_LESS(1,2) == 1 TEST_E - -TEST_B BOOST_PP_GREATER(2,1) == 1 TEST_E -TEST_B BOOST_PP_GREATER(1,1) == 0 TEST_E -TEST_B BOOST_PP_GREATER(1,2) == 0 TEST_E - -TEST_B BOOST_PP_MIN(1,0) == 0 TEST_E -TEST_B BOOST_PP_MIN(1,2) == 1 TEST_E - -TEST_B BOOST_PP_MAX(3,2) == 3 TEST_E -TEST_B BOOST_PP_MAX(4,5) == 5 TEST_E - -TEST_B BOOST_PP_MOD(5,5) == 0 TEST_E -TEST_B BOOST_PP_MOD(9,5) == 4 TEST_E -TEST_B BOOST_PP_MOD(7,4) == 3 TEST_E diff --git a/test/for_test.cpp b/test/for_test.cpp deleted file mode 100644 index 7f6f265..0000000 --- a/test/for_test.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (C) 2001 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -#include -#include - -#include - -/* *** */ - -#ifndef FOR_TEST_MAX -#define FOR_TEST_MAX 50 -#endif - -#define C(D,X) X -#define F(D,X) BOOST_PP_DEC(X) -#define I(D,X) -X - -TEST_B (FOR_TEST_MAX*(FOR_TEST_MAX+1)/2)+1 BOOST_PP_FOR(FOR_TEST_MAX,C,F,I) TEST_E diff --git a/test/list_test.cpp b/test/list_test.cpp deleted file mode 100644 index 39ca282..0000000 --- a/test/list_test.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2001 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -#include -#include -#include -#include -#include - -#include - -/* *** */ - -#define TEST_LIST BOOST_PP_TUPLE_TO_LIST(4,(4,1,5,2)) - -TEST_B BOOST_PP_LIST_FOLD_LEFT(BOOST_PP_SUB_D,22,TEST_LIST) == 10 TEST_E -TEST_B BOOST_PP_LIST_CAT(BOOST_PP_LIST_REVERSE(TEST_LIST)) == 2514 TEST_E -TEST_B BOOST_PP_LIST_FOLD_RIGHT(BOOST_PP_SUB_D,TEST_LIST,0) == 4 TEST_E - -TEST_B BOOST_PP_LIST_CAT(BOOST_PP_LIST_REST_N(2,TEST_LIST)) == 52 TEST_E -TEST_B BOOST_PP_LIST_CAT(BOOST_PP_LIST_FIRST_N(2,TEST_LIST)) == 41 TEST_E - -TEST_B BOOST_PP_LIST_AT(TEST_LIST,2) == 5 TEST_E - -TEST_B BOOST_PP_LIST_SIZE(TEST_LIST) == 4 TEST_E - -TEST_B BOOST_PP_LIST_CAT(BOOST_PP_LIST_TRANSFORM(BOOST_PP_ADD_D,2,TEST_LIST)) == 6374 TEST_E - -TEST_B BOOST_PP_LIST_CAT(BOOST_PP_LIST_APPEND(BOOST_PP_LIST_REST(TEST_LIST),TEST_LIST)) == 1524152 TEST_E - -#define F(I,P,X) +X+P -TEST_B BOOST_PP_LIST_FOR_EACH(F,1,TEST_LIST) == 16 TEST_E -#undef F - -TEST_B BOOST_PP_TUPLE_ELEM(4,3,BOOST_PP_LIST_TO_TUPLE(TEST_LIST)) == 2 TEST_E - -TEST_B BOOST_PP_LIST_CAT(BOOST_PP_LIST_FILTER(BOOST_PP_LESS_D,3,TEST_LIST)) == 45 TEST_E - -#define F(R,X) +BOOST_PP_TUPLE_ELEM(2,0,X)+2-BOOST_PP_TUPLE_ELEM(2,1,X) -TEST_B BOOST_PP_LIST_FOR_EACH_PRODUCT(F,2,(BOOST_PP_TUPLE_TO_LIST(2,(1,0)),BOOST_PP_TUPLE_TO_LIST(2,(2,3)))) == 0 TEST_E -#undef F - -TEST_B BOOST_PP_LIST_CAT(BOOST_PP_LIST_FOLD_RIGHT(BOOST_PP_LIST_APPEND_D, - BOOST_PP_TUPLE_TO_LIST(3, - (BOOST_PP_TUPLE_TO_LIST(2,(0,x)), - BOOST_PP_TUPLE_TO_LIST(4,(A,1,B,2)), - BOOST_PP_TUPLE_TO_LIST(3,(C,3,D)))), - BOOST_PP_LIST_NIL)) == 0xA1B2C3D TEST_E diff --git a/test/logical_test.cpp b/test/logical_test.cpp deleted file mode 100644 index 16ec842..0000000 --- a/test/logical_test.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (C) 2001 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -#include - -#include - -/* *** */ - -TEST_B BOOST_PP_NOT(0) == 1 TEST_E -TEST_B BOOST_PP_NOT(2) == 0 TEST_E - -TEST_B BOOST_PP_AND(0,0) == 0 TEST_E -TEST_B BOOST_PP_AND(0,3) == 0 TEST_E -TEST_B BOOST_PP_AND(4,0) == 0 TEST_E -TEST_B BOOST_PP_AND(5,6) == 1 TEST_E - -TEST_B BOOST_PP_OR(0,0) == 0 TEST_E -TEST_B BOOST_PP_OR(0,7) == 1 TEST_E -TEST_B BOOST_PP_OR(8,0) == 1 TEST_E -TEST_B BOOST_PP_OR(9,1) == 1 TEST_E - -TEST_B BOOST_PP_XOR(0,0) == 0 TEST_E -TEST_B BOOST_PP_XOR(0,2) == 1 TEST_E -TEST_B BOOST_PP_XOR(3,0) == 1 TEST_E -TEST_B BOOST_PP_XOR(4,5) == 0 TEST_E - -TEST_B BOOST_PP_NOR(0,0) == 1 TEST_E -TEST_B BOOST_PP_NOR(0,6) == 0 TEST_E -TEST_B BOOST_PP_NOR(7,0) == 0 TEST_E -TEST_B BOOST_PP_NOR(8,9) == 0 TEST_E diff --git a/test/preprocessor_test.cpp b/test/preprocessor_test.cpp deleted file mode 100644 index 5225a67..0000000 --- a/test/preprocessor_test.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* Copyright (C) 2001 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -#include -#include -#include -#include -#include -#include -#include - -#include - -/* *** */ - -struct Container -{ -#define BOOST_PP_DEF(CV)\ - CV() int& operator[](int i) CV(); - - BOOST_PP_DEF(BOOST_PP_EMPTY) - BOOST_PP_DEF(BOOST_PP_IDENTITY(const)) - BOOST_PP_DEF(BOOST_PP_IDENTITY(volatile)) - BOOST_PP_DEF(BOOST_PP_IDENTITY(const volatile)) - -#undef BOOST_PP_DEF -}; - -/* *** */ - -TEST_B BOOST_PP_IF(BOOST_PP_IF(1,1,1),true,false) && - BOOST_PP_IF(BOOST_PP_IF(0,0,0),false,true) TEST_E - -/* *** */ - -TEST_B BOOST_PP_EXPR_IF(1,1) TEST_E - -/* *** */ - -TEST_B BOOST_PP_CAT(BOOST_PP_IF(1,tru,fals), e) TEST_E - -/* *** */ - -char stringize_test[3] = BOOST_PP_STRINGIZE(__LINE__); - -/* *** */ - -TEST_B BOOST_PP_TUPLE_ELEM(2,0,(1,0)) TEST_E diff --git a/test/repeat_2nd_test.cpp b/test/repeat_2nd_test.cpp deleted file mode 100644 index 2a0f90c..0000000 --- a/test/repeat_2nd_test.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (C) 2001 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -#include -#include -#include -#include -#include - -/* *** */ - -/* RATIONALE: - * - BOOST_PP_REPEAT, BOOST_PP_ENUM, BOOST_PP_REPEAT_FROM_TO and must work - * recursively together. - * - BOOST_PP_REPEAT is already tested with - * BOOST_PP_ENUM_PARAMS. - * - The tested repeat count should exceed imaginable usage. - * - Testing the generation of is_function_helper()s upto 40 arguments should - * be sufficient in this case. Many compilers may fail the repetition tests - * (at least with higher counts). However, the primary purpose of the - * repetition primitives is to enable configurability with reasonable - * defaults, and not necessarily "the most impressive repetition". - * - ENUM_SHIFTED_PARAMS must be tested so that the shifted range is shown to - * be correct. - */ - -#ifndef IS_FUNCTION_HELPER_TEST_MAX -#define IS_FUNCTION_HELPER_TEST_MAX 40 -#endif - -typedef char yes_type; - -#define IS_FUNCTION_HELPER(I,A)\ - template\ - \ - yes_type is_function_helper(\ - P0 (*)(BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PP_INC(I),P))); - -BOOST_PP_REPEAT(BOOST_PP_INC(IS_FUNCTION_HELPER_TEST_MAX),IS_FUNCTION_HELPER,A) - -#undef IS_FUNCTION_HELPER - -/* *** */ - -#define ELEM(_,X) X -#define COL(I,_) - BOOST_PP_TUPLE_ELEM(2,0,(BOOST_PP_ENUM(2,ELEM,I))) -#define ROW(I,_) BOOST_PP_REPEAT(I,COL,_) - -TEST_B 0 == (1 +1+2 +1+2+3) BOOST_PP_REPEAT_FROM_TO(2,5,ROW,_) TEST_E - -#undef ROW -#undef COL -#undef ELEM diff --git a/test/repeat_test.cpp b/test/repeat_test.cpp deleted file mode 100644 index 6de24f2..0000000 --- a/test/repeat_test.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (C) 2001 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -#include -#include -#include -#include -#include -#include - -/* *** */ - -/* RATIONALE: - * - All forms of ENUM_PARAMS must be tested with 0 and n, where n is - * sufficiently large to exceed imaginable usage like. 50 should be - * suffient in this case. - */ - -#ifndef ENUM_PARAMS_TEST_MAX -#define ENUM_PARAMS_TEST_MAX 50 -#endif - -#define CONSTANT(I,A) BOOST_PP_CAT(A,I) = I -const int BOOST_PP_ENUM(ENUM_PARAMS_TEST_MAX, CONSTANT, default_param_); -#undef CONSTANT - -#define TEST_ENUM_PARAMS(N)\ - void BOOST_PP_CAT(test_enum_params,N)(\ - BOOST_PP_ENUM_PARAMS(N, int x));\ - void BOOST_PP_CAT(test_enum_params_with_a_default,N)(\ - BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(N, int x, 0));\ - void BOOST_PP_CAT(test_enum_params_with_defaults,N)(\ - BOOST_PP_ENUM_PARAMS_WITH_DEFAULTS(N, int x, default_param_)); - -TEST_ENUM_PARAMS(0) -TEST_ENUM_PARAMS(ENUM_PARAMS_TEST_MAX) - -#undef TEST_ENUM_PARAMS - -template -struct no_rescan; - -/* *** */ - -#define F(I,P) P I -TEST_B 1 + (4+5+6) BOOST_PP_REPEAT_FROM_TO(4,7,F,-) TEST_E -#undef F diff --git a/test/test.hpp b/test/test.hpp deleted file mode 100644 index 11b5796..0000000 --- a/test/test.hpp +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef BOOST_LIBS_PREPROCESSOR_TEST_TEST_HPP -#define BOOST_LIBS_PREPROCESSOR_TEST_TEST_HPP - -/* Copyright (C) 2001 - * Housemarque Oy - * http://www.housemarque.com - * - * 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. - */ - -#include - -/* The TEST macro has been broken into two pieces to avoid - * double expansion: - * 1. as a macro argument - * 2. rescan - */ -#define TEST_B typedef int BOOST_PP_CAT(test_,__LINE__)[(( -#define TEST_E )==1) ? 1 : -1]; - -#define MACRO(X) X -#define MACRO_ARGS(X) (X) -#endif diff --git a/test/trivial_test.cpp b/test/trivial_test.cpp deleted file mode 100644 index ee0c374..0000000 --- a/test/trivial_test.cpp +++ /dev/null @@ -1,12 +0,0 @@ -/* 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. - */ - -/* This simply attempts to include all preprocessor library headers. */ -#include