assert_is_number.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. @code
  24. returns = Normally the macro returns nothing.
  25. If the sequence is a number, nothing is
  26. output.
  27. For VC++, because there is no sure way of forcing
  28. a compiler error from within a macro without producing
  29. output, if the sequence is not a number the
  30. macro forces a compiler error by outputting invalid C++.
  31. For all other compilers a compiler error is forced
  32. without producing output if the sequence is not a
  33. number.
  34. @endcode
  35. */
  36. #if !BOOST_VMD_ASSERT_DATA
  37. #define BOOST_VMD_ASSERT_IS_NUMBER(sequence)
  38. #else
  39. #include <boost/vmd/assert.hpp>
  40. #include <boost/vmd/is_number.hpp>
  41. #define BOOST_VMD_ASSERT_IS_NUMBER(sequence) \
  42. BOOST_VMD_ASSERT \
  43. ( \
  44. BOOST_VMD_IS_NUMBER(sequence), \
  45. BOOST_VMD_IS_NUMBER_ASSERT_ERROR \
  46. ) \
  47. /**/
  48. #endif // !BOOST_VMD_ASSERT_DATA
  49. #endif /* BOOST_PP_VARIADICS */
  50. #endif /* BOOST_VMD_ASSERT_IS_NUMBER_HPP */