assert.hpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_DETAIL_ASSERT_HPP)
  6. #define BOOST_VMD_DETAIL_ASSERT_HPP
  7. #include <boost/preprocessor/debug/assert.hpp>
  8. #include <boost/preprocessor/variadic/elem.hpp>
  9. #if BOOST_VMD_MSVC
  10. #include <boost/preprocessor/comparison/equal.hpp>
  11. #include <boost/preprocessor/control/if.hpp>
  12. #include <boost/preprocessor/control/iif.hpp>
  13. #include <boost/preprocessor/variadic/size.hpp>
  14. #include <boost/vmd/empty.hpp>
  15. #define BOOST_VMD_DETAIL_ASSERT_VC_GEN_ERROR_OUTPUT(errstr) \
  16. BOOST_PP_ASSERT(0) \
  17. typedef char errstr[-1]; \
  18. /**/
  19. #define BOOST_VMD_DETAIL_ASSERT_VC_GEN_ERROR_DEFAULT(...) \
  20. BOOST_VMD_DETAIL_ASSERT_VC_GEN_ERROR_OUTPUT(BOOST_VMD_ASSERT_ERROR) \
  21. /**/
  22. #define BOOST_VMD_DETAIL_ASSERT_VC_GEN_ERROR_ERRSTR(...) \
  23. BOOST_VMD_DETAIL_ASSERT_VC_GEN_ERROR_OUTPUT(BOOST_PP_VARIADIC_ELEM(1,__VA_ARGS__)) \
  24. /**/
  25. #define BOOST_VMD_DETAIL_ASSERT_TRUE(...) \
  26. BOOST_PP_IIF \
  27. ( \
  28. BOOST_PP_EQUAL \
  29. ( \
  30. BOOST_PP_VARIADIC_SIZE(__VA_ARGS__), \
  31. 1 \
  32. ), \
  33. BOOST_VMD_DETAIL_ASSERT_VC_GEN_ERROR_DEFAULT, \
  34. BOOST_VMD_DETAIL_ASSERT_VC_GEN_ERROR_ERRSTR \
  35. ) \
  36. (__VA_ARGS__) \
  37. /**/
  38. #define BOOST_VMD_DETAIL_ASSERT(...) \
  39. BOOST_PP_IF \
  40. ( \
  41. BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__), \
  42. BOOST_VMD_EMPTY, \
  43. BOOST_VMD_DETAIL_ASSERT_TRUE \
  44. ) \
  45. (__VA_ARGS__) \
  46. /**/
  47. #else
  48. #define BOOST_VMD_DETAIL_ASSERT_DO(cond) \
  49. BOOST_PP_ASSERT(cond) \
  50. /**/
  51. #define BOOST_VMD_DETAIL_ASSERT(...) \
  52. BOOST_VMD_DETAIL_ASSERT_DO(BOOST_PP_VARIADIC_ELEM(0,__VA_ARGS__)) \
  53. /**/
  54. #endif /* BOOST_VMD_MSVC */
  55. #endif /* BOOST_VMD_DETAIL_ASSERT_HPP */