assert.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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. @code
  26. typedef char errstr[-1];
  27. @endcode
  28. The errstr defaults to BOOST_VMD_ASSERT_ERROR if not supplied.
  29. It is only relevant for VC++.
  30. returns = If cond expands to 0, this macro causes an error. Otherwise, it expands to nothing.
  31. For all compilers other than Visual C++ the error is a preprocessing error.
  32. For Visual C++ the error is caused by output invalid C++: this error could be
  33. masked if the invalid output is ignored by a macro which invokes this macro.
  34. */
  35. # define BOOST_VMD_ASSERT(...) \
  36. BOOST_VMD_DETAIL_ASSERT(__VA_ARGS__) \
  37. /**/
  38. #endif /* BOOST_PP_VARIADICS */
  39. #endif /* BOOST_VMD_ASSERT_HPP */