assert_is_empty.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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_ASSERT_IS_EMPTY_HPP)
  6. #define BOOST_VMD_ASSERT_IS_EMPTY_HPP
  7. #include <boost/vmd/detail/setup.hpp>
  8. #if BOOST_PP_VARIADICS
  9. #if BOOST_VMD_ASSERT_DATA
  10. #include <boost/vmd/assert.hpp>
  11. #include <boost/vmd/is_empty.hpp>
  12. #endif
  13. /*
  14. The succeeding comments in this file are in doxygen format.
  15. */
  16. /** \file
  17. */
  18. /** \def BOOST_VMD_ASSERT_IS_EMPTY(...)
  19. \brief Asserts that the input is empty.
  20. The macro checks to see if the input is empty or not.
  21. If it is not empty, it forces a compiler error.
  22. The macro is a variadic macro taking any input.
  23. For the VC++8 compiler (VS2005) the macro takes a single parameter of input to check and not variadic data.
  24. The macro normally checks for emptiness only in
  25. debug mode. However an end-user can force the macro
  26. to check or not check by defining the macro
  27. BOOST_VMD_ASSERT_DATA to 1 or 0 respectively.
  28. .... = variadic input, for VC++8 this must be a single parameter.
  29. @code
  30. returns = Normally the macro returns nothing.
  31. If the input is empty, nothing is output.
  32. For VC++, because there is no sure way of forcing
  33. a compiler error from within a macro without producing
  34. output, if the input is not empty the
  35. macro forces a compiler error by outputting invalid C++.
  36. For all other compilers a compiler error is forced
  37. without producing output if the input is not empty.
  38. @endcode
  39. It is recommended to append BOOST_PP_EMPTY() to whatever input
  40. is being tested in order to avoid possible warning messages
  41. from some compilers about no parameters being passed to the macro
  42. when the input is truly empty.
  43. */
  44. #if BOOST_VMD_MSVC_V8
  45. #if !BOOST_VMD_ASSERT_DATA
  46. #define BOOST_VMD_ASSERT_IS_EMPTY(input)
  47. #else
  48. #define BOOST_VMD_ASSERT_IS_EMPTY(input) \
  49. BOOST_VMD_ASSERT \
  50. ( \
  51. BOOST_VMD_IS_EMPTY(input), \
  52. BOOST_VMD_IS_EMPTY_ASSERT_ERROR \
  53. ) \
  54. /**/
  55. #endif // !BOOST_VMD_ASSERT_DATA
  56. #else
  57. #if !BOOST_VMD_ASSERT_DATA
  58. #define BOOST_VMD_ASSERT_IS_EMPTY(...)
  59. #else
  60. #define BOOST_VMD_ASSERT_IS_EMPTY(...) \
  61. BOOST_VMD_ASSERT \
  62. ( \
  63. BOOST_VMD_IS_EMPTY(__VA_ARGS__), \
  64. BOOST_VMD_IS_EMPTY_ASSERT_ERROR \
  65. ) \
  66. /**/
  67. #endif // !BOOST_VMD_ASSERT_DATA
  68. #endif /* BOOST_VMD_MSVC_V8 */
  69. #endif /* BOOST_PP_VARIADICS */
  70. #endif /* BOOST_VMD_ASSERT_IS_EMPTY_HPP */