vaopt.cxx 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. # /* **************************************************************************
  2. # * *
  3. # * (C) Copyright Edward Diener 2019.
  4. # * Distributed under the Boost Software License, Version 1.0. (See
  5. # * accompanying file LICENSE_1_0.txt or copy at
  6. # * http://www.boost.org/LICENSE_1_0.txt)
  7. # * *
  8. # ************************************************************************** */
  9. #
  10. # /* See http://www.boost.org for most recent version. */
  11. #
  12. # include <libs/preprocessor/test/test.h>
  13. # include <boost/preprocessor/variadic/has_opt.hpp>
  14. # if BOOST_PP_VARIADIC_HAS_OPT()
  15. # include <boost/preprocessor/facilities/empty.hpp>
  16. # include <boost/preprocessor/facilities/va_opt.hpp>
  17. # include <boost/preprocessor/variadic/elem.hpp>
  18. #define DATA
  19. #define OBJECT OBJECT2
  20. #define OBJECT2
  21. #define FUNC(x) FUNC2(x)
  22. #define FUNC2(x)
  23. #define FUNC_GEN() ()
  24. #define FUNC_GEN2(x) ()
  25. #define FUNC_GEN3() (&)
  26. #define FUNC_GEN4(x) (y)
  27. #define FUNC_GEN5() (y,z)
  28. #define FUNC_GEN6() anything
  29. #define FUNC_GEN7(x) anything
  30. #define FUNC_GEN8(x,y) (1,2,3)
  31. #define FUNC_GEN9(x,y,z) anything
  32. #define FUNC_GEN10(x) (y) data
  33. #define NAME &name
  34. #define ATUPLE (atuple)
  35. #define ATUPLE_PLUS (atuple) data
  36. #define TRY_PASS_EMPTY_STD(...) BOOST_PP_VARIADIC_ELEM(0, __VA_OPT__ (0,) 1)
  37. #define TRY_PASS_EMPTY_BOOST(...) BOOST_PP_VARIADIC_ELEM(0,BOOST_PP_VA_OPT((0),(1),__VA_ARGS__))
  38. BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN) == 0 END
  39. BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN) == 0 END
  40. BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN2) == 0 END
  41. BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN2) == 0 END
  42. BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN3) == 0 END
  43. BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN3) == 0 END
  44. BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN4) == 0 END
  45. BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN4) == 0 END
  46. BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN5) == 0 END
  47. BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN5) == 0 END
  48. BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN8) == 0 END
  49. BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN8) == 0 END
  50. BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN9) == 0 END
  51. BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN9) == 0 END
  52. BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN10) == 0 END
  53. BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN10) == 0 END
  54. BEGIN TRY_PASS_EMPTY_STD(BOOST_PP_EMPTY()) == 1 END
  55. BEGIN TRY_PASS_EMPTY_BOOST(BOOST_PP_EMPTY()) == 1 END
  56. BEGIN TRY_PASS_EMPTY_STD(DATA BOOST_PP_EMPTY()) == 1 END
  57. BEGIN TRY_PASS_EMPTY_BOOST(DATA BOOST_PP_EMPTY()) == 1 END
  58. BEGIN TRY_PASS_EMPTY_STD() == 1 END
  59. BEGIN TRY_PASS_EMPTY_BOOST() == 1 END
  60. BEGIN TRY_PASS_EMPTY_STD(DATA) == 1 END
  61. BEGIN TRY_PASS_EMPTY_BOOST(DATA) == 1 END
  62. BEGIN TRY_PASS_EMPTY_STD(x BOOST_PP_EMPTY()) == 0 END
  63. BEGIN TRY_PASS_EMPTY_BOOST(x BOOST_PP_EMPTY()) == 0 END
  64. BEGIN TRY_PASS_EMPTY_STD(OBJECT BOOST_PP_EMPTY()) == 1 END
  65. BEGIN TRY_PASS_EMPTY_BOOST(OBJECT BOOST_PP_EMPTY()) == 1 END
  66. BEGIN TRY_PASS_EMPTY_STD(FUNC(z) BOOST_PP_EMPTY()) == 1 END
  67. BEGIN TRY_PASS_EMPTY_BOOST(FUNC(z) BOOST_PP_EMPTY()) == 1 END
  68. BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN6) == 0 END
  69. BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN6) == 0 END
  70. BEGIN TRY_PASS_EMPTY_STD(FUNC_GEN7) == 0 END
  71. BEGIN TRY_PASS_EMPTY_BOOST(FUNC_GEN7) == 0 END
  72. BEGIN TRY_PASS_EMPTY_STD(NAME) == 0 END
  73. BEGIN TRY_PASS_EMPTY_BOOST(NAME) == 0 END
  74. BEGIN TRY_PASS_EMPTY_STD(ATUPLE) == 0 END
  75. BEGIN TRY_PASS_EMPTY_BOOST(ATUPLE) == 0 END
  76. BEGIN TRY_PASS_EMPTY_STD(ATUPLE_PLUS) == 0 END
  77. BEGIN TRY_PASS_EMPTY_BOOST(ATUPLE_PLUS) == 0 END
  78. # else
  79. BEGIN 1 == 1 END
  80. # endif