isempty.cxx 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. # /* **************************************************************************
  2. # * *
  3. # * (C) Copyright Edward Diener 2014.
  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 <boost/preprocessor/config/config.hpp>
  13. #
  14. #if (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()) || (BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC())
  15. # include <boost/preprocessor/facilities/empty.hpp>
  16. # include <boost/preprocessor/facilities/is_empty.hpp>
  17. # include <libs/preprocessor/test/test.h>
  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. #if BOOST_PP_VARIADICS
  37. # include <boost/preprocessor/variadic/has_opt.hpp>
  38. #if defined(__cplusplus) && __cplusplus > 201703L && BOOST_PP_VARIADIC_HAS_OPT()
  39. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END
  40. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END
  41. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END
  42. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END
  43. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END
  44. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
  45. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
  46. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END
  47. #elif BOOST_PP_VARIADICS_MSVC /* Testing the VC++ variadic version */
  48. /* INCORRECT */
  49. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 1 END
  50. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 1 END
  51. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 1 END
  52. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 1 END
  53. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 1 END
  54. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 1 END
  55. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 1 END
  56. /* CORRECT */
  57. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
  58. #else /* Testing the non-VC++ variadic version */
  59. /* CORRECT */
  60. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END
  61. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END
  62. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END
  63. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END
  64. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END
  65. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END
  66. /* COMPILER ERROR */
  67. // BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
  68. // BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
  69. #endif
  70. /* Testing the variadic version */
  71. /* CORRECT */
  72. BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END
  73. BEGIN BOOST_PP_IS_EMPTY(DATA BOOST_PP_EMPTY()) == 1 END
  74. BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 END
  75. BEGIN BOOST_PP_IS_EMPTY(OBJECT BOOST_PP_EMPTY()) == 1 END
  76. BEGIN BOOST_PP_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()) == 1 END
  77. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN6) == 0 END
  78. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN7) == 0 END
  79. BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END
  80. BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 0 END
  81. BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 0 END
  82. #else
  83. #if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC() /* Testing the VC++ non-variadic version */
  84. /* INCORRECT */
  85. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 1 END
  86. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 1 END
  87. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 1 END
  88. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 1 END
  89. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 1 END
  90. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 1 END
  91. BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 1 END
  92. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 1 END
  93. BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 1 END
  94. /* CORRECT */
  95. BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END
  96. #else /* Testing the non-VC++ non-variadic version */
  97. /* CORRECT */
  98. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN) == 0 END
  99. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN2) == 0 END
  100. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN3) == 0 END
  101. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN4) == 0 END
  102. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN5) == 0 END
  103. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN8) == 0 END
  104. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN10) == 0 END
  105. /* UNDEFINED BEHAVIOR */
  106. // BEGIN BOOST_PP_IS_EMPTY(ATUPLE) == 0 END
  107. // BEGIN BOOST_PP_IS_EMPTY(ATUPLE_PLUS) == 1 END
  108. // BEGIN BOOST_PP_IS_EMPTY(NAME) == 0 END
  109. #endif
  110. /* Testing the non-variadic version */
  111. /* CORRECT */
  112. BEGIN BOOST_PP_IS_EMPTY(BOOST_PP_EMPTY()) == 1 END
  113. BEGIN BOOST_PP_IS_EMPTY(DATA BOOST_PP_EMPTY()) == 1 END
  114. BEGIN BOOST_PP_IS_EMPTY(x BOOST_PP_EMPTY()) == 0 END
  115. BEGIN BOOST_PP_IS_EMPTY(OBJECT BOOST_PP_EMPTY()) == 1 END
  116. BEGIN BOOST_PP_IS_EMPTY(FUNC(z) BOOST_PP_EMPTY()) == 1 END
  117. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN6) == 0 END
  118. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN7) == 0 END
  119. BEGIN BOOST_PP_IS_EMPTY(FUNC_GEN9) == 0 END
  120. #endif
  121. #endif