1 /*============================================================================= 2 Boost.Wave: A Standard compliant C++ preprocessor library 3 http://www.boost.org/ 4 5 Copyright (c) 2001-2012 Hartmut Kaiser. Distributed under the Boost 6 Software License, Version 1.0. (See accompanying file 7 LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 8 =============================================================================*/ 9 10 // Tests simple expression arithmetics 11 12 # define CAT(a, b) PRIMITIVE_CAT(a, b) 13 # define PRIMITIVE_CAT(a, b) a ## b 14 15 # define OFFSET(n) OFFSET_ ## n 16 17 # define OFFSET_1 OFFSET_2 % 10 18 # define OFFSET_2 OFFSET_3 % 100 19 # define OFFSET_3 OFFSET_4 % 1000 20 # define OFFSET_4 21 22 # define FACTOR(n) FACTOR_ ## n 23 24 # define FACTOR_1 / 1 25 # define FACTOR_2 CAT(FACTOR_1, 0) 26 # define FACTOR_3 CAT(FACTOR_2, 0) 27 # define FACTOR_4 CAT(FACTOR_3, 0) 28 29 # define DIGIT(n) OFFSET(n) FACTOR(n) 30 31 # define x 987 32 33 # if (x) DIGIT(3) == 0 34 # define D3 0 35 # elif (x) DIGIT(3) == 1 36 # define D3 1 37 # elif (x) DIGIT(3) == 2 38 # define D3 2 39 # elif (x) DIGIT(3) == 3 40 # define D3 3 41 # elif (x) DIGIT(3) == 4 42 # define D3 4 43 # elif (x) DIGIT(3) == 5 44 # define D3 5 45 # elif (x) DIGIT(3) == 6 46 # define D3 6 47 # elif (x) DIGIT(3) == 7 48 # define D3 7 49 # elif (x) DIGIT(3) == 8 50 # define D3 8 51 # elif (x) DIGIT(3) == 9 52 # define D3 9 53 # endif 54 55 # if (x) DIGIT(2) == 0 56 # define D2 0 57 # elif (x) DIGIT(2) == 1 58 # define D2 1 59 # elif (x) DIGIT(2) == 2 60 # define D2 2 61 # elif (x) DIGIT(2) == 3 62 # define D2 3 63 # elif (x) DIGIT(2) == 4 64 # define D2 4 65 # elif (x) DIGIT(2) == 5 66 # define D2 5 67 # elif (x) DIGIT(2) == 6 68 # define D2 6 69 # elif (x) DIGIT(2) == 7 70 # define D2 7 71 # elif (x) DIGIT(2) == 8 72 # define D2 8 73 # elif (x) DIGIT(2) == 9 74 # define D2 9 75 # endif 76 77 # if (x) DIGIT(1) == 0 78 # define D1 0 79 # elif (x) DIGIT(1) == 1 80 # define D1 1 81 # elif (x) DIGIT(1) == 2 82 # define D1 2 83 # elif (x) DIGIT(1) == 3 84 # define D1 3 85 # elif (x) DIGIT(1) == 4 86 # define D1 4 87 # elif (x) DIGIT(1) == 5 88 # define D1 5 89 # elif (x) DIGIT(1) == 6 90 # define D1 6 91 # elif (x) DIGIT(1) == 7 92 # define D1 7 93 # elif (x) DIGIT(1) == 8 94 # define D1 8 95 # elif (x) DIGIT(1) == 9 96 # define D1 9 97 # endif 98 99 //R #line 100 "t_4_003.cpp" 100 D3 D2 D1 //R 9 8 7 101