t_1_032.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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. // Test partial macro evaluation using varidic macros
  9. //O --variadics
  10. #define cat(...) cat_i(__VA_ARGS__,,,,,)
  11. #define cat_i(a, b, c, d, e, ...) \
  12. a ## b ## c ## d ## e \
  13. /**/
  14. #define primitive_cat(a, b) a ## b
  15. #define partial_cat(x, y) cat(partial_cat_, x, y)
  16. #define partial_cat_00(a, b) partial_cat_f(, ## a, b ## ,)
  17. #define partial_cat_01(a, b) partial_cat_f(, ## a, b ,)
  18. #define partial_cat_10(a, b) partial_cat_f(, a, b ## ,)
  19. #define partial_cat_11(a, b) partial_cat_f(, a, b ,)
  20. #define partial_cat_f(a, b, c, d) b ## c
  21. #define X Token1
  22. #define Y Token2
  23. //R #line 34 "t_1_032.cpp"
  24. partial_cat(0, 0)(X, Y) //R XY
  25. partial_cat(0, 1)(X, Y) //R XToken2
  26. partial_cat(1, 0)(X, Y) //R Token1Y
  27. partial_cat(1, 1)(X, Y) //R Token1Token2