assert_is_number.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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_NUMBER_HPP)
  6. #define BOOST_VMD_ASSERT_IS_NUMBER_HPP
  7. #include <boost/vmd/detail/setup.hpp>
  8. #if BOOST_PP_VARIADICS
  9. /*
  10. The succeeding comments in this file are in doxygen format.
  11. */
  12. /** \file
  13. */
  14. /** \def BOOST_VMD_ASSERT_IS_NUMBER(sequence)
  15. \brief Asserts that the sequence is a number.
  16. The macro checks that the parameter is a number.
  17. If it is not a number, it forces a compiler error.
  18. The macro normally checks for a number only in
  19. debug mode. However an end-user can force the macro
  20. to check or not check by defining the macro
  21. BOOST_VMD_ASSERT_DATA to 1 or 0 respectively.
  22. sequence = a possible number.
  23. returns = Normally the macro returns nothing.
  24. If the sequence is a number, nothing is
  25. output.
  26. For VC++, because there is no sure way of forcing
  27. a compiler error from within a macro without producing
  28. output, if the sequence is not a number the
  29. macro forces a compiler error by outputting invalid C++.
  30. For all other compilers a compiler error is forced
  31. without producing output if the sequence is not a
  32. number.
  33. */
  34. #if !BOOST_VMD_ASSERT_DATA
  35. #define BOOST_VMD_ASSERT_IS_NUMBER(sequence)
  36. #else
  37. #include <boost/vmd/assert.hpp>
  38. #include <boost/vmd/is_number.hpp>
  39. #define BOOST_VMD_ASSERT_IS_NUMBER(sequence) \
  40. BOOST_VMD_ASSERT \
  41. ( \
  42. BOOST_VMD_IS_NUMBER(sequence), \
  43. BOOST_VMD_IS_NUMBER_ASSERT_ERROR \
  44. ) \
  45. /**/
  46. #endif // !BOOST_VMD_ASSERT_DATA
  47. #endif /* BOOST_PP_VARIADICS */
  48. #endif /* BOOST_VMD_ASSERT_IS_NUMBER_HPP */