assert_is_empty.hpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. returns = Normally the macro returns nothing.
  30. If the input is empty, nothing is output.
  31. For VC++, because there is no sure way of forcing
  32. a compiler error from within a macro without producing
  33. output, if the input is not empty the
  34. macro forces a compiler error by outputting invalid C++.
  35. For all other compilers a compiler error is forced
  36. without producing output if the input is not empty.
  37. It is recommended to append BOOST_PP_EMPTY() to whatever input
  38. is being tested in order to avoid possible warning messages
  39. from some compilers about no parameters being passed to the macro
  40. when the input is truly empty.
  41. */
  42. #if BOOST_VMD_MSVC_V8
  43. #if !BOOST_VMD_ASSERT_DATA
  44. #define BOOST_VMD_ASSERT_IS_EMPTY(input)
  45. #else
  46. #define BOOST_VMD_ASSERT_IS_EMPTY(input) \
  47. BOOST_VMD_ASSERT \
  48. ( \
  49. BOOST_VMD_IS_EMPTY(input), \
  50. BOOST_VMD_IS_EMPTY_ASSERT_ERROR \
  51. ) \
  52. /**/
  53. #endif // !BOOST_VMD_ASSERT_DATA
  54. #else
  55. #if !BOOST_VMD_ASSERT_DATA
  56. #define BOOST_VMD_ASSERT_IS_EMPTY(...)
  57. #else
  58. #define BOOST_VMD_ASSERT_IS_EMPTY(...) \
  59. BOOST_VMD_ASSERT \
  60. ( \
  61. BOOST_VMD_IS_EMPTY(__VA_ARGS__), \
  62. BOOST_VMD_IS_EMPTY_ASSERT_ERROR \
  63. ) \
  64. /**/
  65. #endif // !BOOST_VMD_ASSERT_DATA
  66. #endif /* BOOST_VMD_MSVC_V8 */
  67. #endif /* BOOST_PP_VARIADICS */
  68. #endif /* BOOST_VMD_ASSERT_IS_EMPTY_HPP */