is_empty.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // (C) Copyright Edward Diener 2011-2015
  2. // Use, modification and distribution are subject to the Boost Software License,
  3. // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt).
  5. #if !defined(BOOST_VMD_IS_EMPTY_HPP)
  6. #define BOOST_VMD_IS_EMPTY_HPP
  7. #include <boost/vmd/detail/setup.hpp>
  8. #if BOOST_PP_VARIADICS
  9. #include <boost/preprocessor/punctuation/is_begin_parens.hpp>
  10. #include <boost/vmd/detail/is_empty.hpp>
  11. /*
  12. The succeeding comments in this file are in doxygen format.
  13. */
  14. /** \file
  15. */
  16. /** \def BOOST_VMD_IS_EMPTY(...)
  17. \brief Tests whether its input is empty or not.
  18. The macro checks to see if the input is empty or not.
  19. It returns 1 if the input is empty, else returns 0.
  20. The macro is a variadic macro taking any input.
  21. For the VC++8 compiler (VS2005) the macro takes a single parameter of input to check.
  22. The macro is not perfect, and can not be so. The problem
  23. area is if the input to be checked is a function-like
  24. macro name, in which case either a compiler error can result
  25. or a false result can occur.
  26. This macro is a replacement, using variadic macro support,
  27. for the undocumented macro BOOST_PP_IS_EMPTY in the Boost
  28. PP library. The code is taken from a posting by Paul Mensonides
  29. of a variadic version for BOOST_PP_IS_EMPTY, and changed
  30. in order to also support VC++.
  31. .... = variadic input, for VC++8 this must be a single parameter
  32. returns = 1 if the input is empty, 0 if it is not
  33. It is recommended to append BOOST_PP_EMPTY() to whatever input
  34. is being tested in order to avoid possible warning messages
  35. from some compilers about no parameters being passed to the macro
  36. when the input is truly empty.
  37. */
  38. #if BOOST_VMD_MSVC_V8
  39. #define BOOST_VMD_IS_EMPTY(sequence) \
  40. BOOST_VMD_DETAIL_IS_EMPTY_IIF \
  41. ( \
  42. BOOST_PP_IS_BEGIN_PARENS \
  43. ( \
  44. sequence \
  45. ) \
  46. ) \
  47. ( \
  48. BOOST_VMD_DETAIL_IS_EMPTY_GEN_ZERO, \
  49. BOOST_VMD_DETAIL_IS_EMPTY_PROCESS \
  50. ) \
  51. (sequence) \
  52. /**/
  53. #else
  54. #define BOOST_VMD_IS_EMPTY(...) \
  55. BOOST_VMD_DETAIL_IS_EMPTY_IIF \
  56. ( \
  57. BOOST_PP_IS_BEGIN_PARENS \
  58. ( \
  59. __VA_ARGS__ \
  60. ) \
  61. ) \
  62. ( \
  63. BOOST_VMD_DETAIL_IS_EMPTY_GEN_ZERO, \
  64. BOOST_VMD_DETAIL_IS_EMPTY_PROCESS \
  65. ) \
  66. (__VA_ARGS__) \
  67. /**/
  68. #endif /* BOOST_VMD_MSVC_V8 */
  69. #endif /* BOOST_PP_VARIADICS */
  70. #endif /* BOOST_VMD_IS_EMPTY_HPP */