assert_is_list.hpp 3.4 KB

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