assert_is_seq.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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_SEQ_HPP)
  6. #define BOOST_VMD_ASSERT_IS_SEQ_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_SEQ(sequence)
  15. \brief Asserts that the sequence is a Boost PP seq.
  16. The macro checks that the sequence is a Boost PP seq.
  17. If it is not a Boost PP seq, it forces a compiler error.
  18. The macro normally checks for a Boost PP seq 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 Boost PP seq.
  23. returns = Normally the macro returns nothing.
  24. If the sequence is a Boost PP seq, 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 Boost PP seq 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. Boost PP seq.
  33. */
  34. /** \def BOOST_VMD_ASSERT_IS_SEQ_D(d,sequence)
  35. \brief Asserts that the sequence is a Boost PP seq. Re-entrant version.
  36. The macro checks that the sequence is a Boost PP seq.
  37. If it is not a Boost PP seq, it forces a compiler error.
  38. The macro normally checks for a Boost PP seq only in
  39. debug mode. However an end-user can force the macro
  40. to check or not check by defining the macro
  41. BOOST_VMD_ASSERT_DATA to 1 or 0 respectively.
  42. d = The next available BOOST_PP_WHILE iteration.
  43. sequence = a possible Boost PP seq.
  44. returns = Normally the macro returns nothing.
  45. If the sequence is a Boost PP seq, nothing is
  46. output.
  47. For VC++, because there is no sure way of forcing
  48. a compiler error from within a macro without producing
  49. output, if the sequence is not a Boost PP seq the
  50. macro forces a compiler error by outputting invalid C++.
  51. For all other compilers a compiler error is forced
  52. without producing output if the sequence is not a
  53. Boost PP seq.
  54. */
  55. #if !BOOST_VMD_ASSERT_DATA
  56. #define BOOST_VMD_ASSERT_IS_SEQ(sequence)
  57. #define BOOST_VMD_ASSERT_IS_SEQ_D(d,sequence)
  58. #else
  59. #include <boost/vmd/assert.hpp>
  60. #include <boost/vmd/is_seq.hpp>
  61. #define BOOST_VMD_ASSERT_IS_SEQ(sequence) \
  62. BOOST_VMD_ASSERT \
  63. ( \
  64. BOOST_VMD_IS_SEQ(sequence), \
  65. BOOST_VMD_ASSERT_IS_SEQ_ERROR \
  66. ) \
  67. /**/
  68. #define BOOST_VMD_ASSERT_IS_SEQ_D(d,sequence) \
  69. BOOST_VMD_ASSERT \
  70. ( \
  71. BOOST_VMD_IS_SEQ_D(d,sequence), \
  72. BOOST_VMD_ASSERT_IS_SEQ_ERROR \
  73. ) \
  74. /**/
  75. #endif /* BOOST_VMD_ASSERT_DATA */
  76. #endif /* BOOST_PP_VARIADICS */
  77. #endif /* BOOST_VMD_ASSERT_IS_SEQ_HPP */