t_4_003.cpp 2.2 KB

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