9
3

assert.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_HPP)
  6. #define BOOST_VMD_ASSERT_HPP
  7. #include <boost/vmd/detail/setup.hpp>
  8. #if BOOST_PP_VARIADICS
  9. #include <boost/vmd/detail/assert.hpp>
  10. /*
  11. The succeeding comments in this file are in doxygen format.
  12. */
  13. /** \file
  14. */
  15. /** \def BOOST_VMD_ASSERT(...)
  16. \brief Conditionally causes an error to be generated.
  17. ... = variadic parameters, maximum of 2 will be considered.
  18. Any variadic parameters beyond the maximum of 2 are just ignored.
  19. The first variadic parameter is:
  20. cond = A condition that determines whether an assertion occurs. Valid values range from 0 to BOOST_PP_LIMIT_MAG.
  21. The second variadic parameter (optional) is:
  22. errstr = An error string for generating a compiler error when using the VC++ compiler.
  23. The VC++ compiler is incapable of producing a preprocessor error so when the 'cond'
  24. is 0, a compiler error is generated by outputting C++ code in the form of:
  25. typedef char errstr[-1];
  26. The errstr defaults to BOOST_VMD_ASSERT_ERROR if not supplied.
  27. It is only relevant for VC++.
  28. returns = If cond expands to 0, this macro causes an error. Otherwise, it expands to nothing.
  29. For all compilers other than Visual C++ the error is a preprocessing error.
  30. For Visual C++ the error is caused by output invalid C++: this error could be
  31. masked if the invalid output is ignored by a macro which invokes this macro.
  32. */
  33. # define BOOST_VMD_ASSERT(...) \
  34. BOOST_VMD_DETAIL_ASSERT(__VA_ARGS__) \
  35. /**/
  36. #endif /* BOOST_PP_VARIADICS */
  37. #endif /* BOOST_VMD_ASSERT_HPP */