enum_trailing.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # /* **************************************************************************
  2. # * *
  3. # * (C) Copyright Paul Mensonides 2002.
  4. # * Distributed under the Boost Software License, Version 1.0. (See
  5. # * accompanying file LICENSE_1_0.txt or copy at
  6. # * http://www.boost.org/LICENSE_1_0.txt)
  7. # * *
  8. # ************************************************************************** */
  9. #
  10. # /* See http://www.boost.org for most recent version. */
  11. #
  12. # ifndef BOOST_PREPROCESSOR_REPETITION_ENUM_TRAILING_HPP
  13. # define BOOST_PREPROCESSOR_REPETITION_ENUM_TRAILING_HPP
  14. #
  15. # include <boost/preprocessor/cat.hpp>
  16. # include <boost/preprocessor/config/config.hpp>
  17. # include <boost/preprocessor/debug/error.hpp>
  18. # include <boost/preprocessor/detail/auto_rec.hpp>
  19. # include <boost/preprocessor/repetition/repeat.hpp>
  20. # include <boost/preprocessor/tuple/elem.hpp>
  21. # include <boost/preprocessor/tuple/rem.hpp>
  22. #
  23. # /* BOOST_PP_ENUM_TRAILING */
  24. #
  25. # if 0
  26. # define BOOST_PP_ENUM_TRAILING(count, macro, data)
  27. # endif
  28. #
  29. # define BOOST_PP_ENUM_TRAILING BOOST_PP_CAT(BOOST_PP_ENUM_TRAILING_, BOOST_PP_AUTO_REC(BOOST_PP_REPEAT_P, 4))
  30. #
  31. # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
  32. # define BOOST_PP_ENUM_TRAILING_1(c, m, d) BOOST_PP_REPEAT_1(c, BOOST_PP_ENUM_TRAILING_M_1, (m, d))
  33. # define BOOST_PP_ENUM_TRAILING_2(c, m, d) BOOST_PP_REPEAT_2(c, BOOST_PP_ENUM_TRAILING_M_2, (m, d))
  34. # define BOOST_PP_ENUM_TRAILING_3(c, m, d) BOOST_PP_REPEAT_3(c, BOOST_PP_ENUM_TRAILING_M_3, (m, d))
  35. # else
  36. # define BOOST_PP_ENUM_TRAILING_1(c, m, d) BOOST_PP_ENUM_TRAILING_1_I(c, m, d)
  37. # define BOOST_PP_ENUM_TRAILING_2(c, m, d) BOOST_PP_ENUM_TRAILING_2_I(c, m, d)
  38. # define BOOST_PP_ENUM_TRAILING_3(c, m, d) BOOST_PP_ENUM_TRAILING_3_I(c, m, d)
  39. # define BOOST_PP_ENUM_TRAILING_1_I(c, m, d) BOOST_PP_REPEAT_1(c, BOOST_PP_ENUM_TRAILING_M_1, (m, d))
  40. # define BOOST_PP_ENUM_TRAILING_2_I(c, m, d) BOOST_PP_REPEAT_2(c, BOOST_PP_ENUM_TRAILING_M_2, (m, d))
  41. # define BOOST_PP_ENUM_TRAILING_3_I(c, m, d) BOOST_PP_REPEAT_3(c, BOOST_PP_ENUM_TRAILING_M_3, (m, d))
  42. # endif
  43. #
  44. # define BOOST_PP_ENUM_TRAILING_4(c, m, d) BOOST_PP_ERROR(0x0003)
  45. #
  46. # if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_STRICT()
  47. # define BOOST_PP_ENUM_TRAILING_M_1(z, n, md) BOOST_PP_ENUM_TRAILING_M_1_IM(z, n, BOOST_PP_TUPLE_REM_2 md)
  48. # define BOOST_PP_ENUM_TRAILING_M_2(z, n, md) BOOST_PP_ENUM_TRAILING_M_2_IM(z, n, BOOST_PP_TUPLE_REM_2 md)
  49. # define BOOST_PP_ENUM_TRAILING_M_3(z, n, md) BOOST_PP_ENUM_TRAILING_M_3_IM(z, n, BOOST_PP_TUPLE_REM_2 md)
  50. # define BOOST_PP_ENUM_TRAILING_M_1_IM(z, n, im) BOOST_PP_ENUM_TRAILING_M_1_I(z, n, im)
  51. # define BOOST_PP_ENUM_TRAILING_M_2_IM(z, n, im) BOOST_PP_ENUM_TRAILING_M_2_I(z, n, im)
  52. # define BOOST_PP_ENUM_TRAILING_M_3_IM(z, n, im) BOOST_PP_ENUM_TRAILING_M_3_I(z, n, im)
  53. # else
  54. # define BOOST_PP_ENUM_TRAILING_M_1(z, n, md) BOOST_PP_ENUM_TRAILING_M_1_I(z, n, BOOST_PP_TUPLE_ELEM(2, 0, md), BOOST_PP_TUPLE_ELEM(2, 1, md))
  55. # define BOOST_PP_ENUM_TRAILING_M_2(z, n, md) BOOST_PP_ENUM_TRAILING_M_2_I(z, n, BOOST_PP_TUPLE_ELEM(2, 0, md), BOOST_PP_TUPLE_ELEM(2, 1, md))
  56. # define BOOST_PP_ENUM_TRAILING_M_3(z, n, md) BOOST_PP_ENUM_TRAILING_M_3_I(z, n, BOOST_PP_TUPLE_ELEM(2, 0, md), BOOST_PP_TUPLE_ELEM(2, 1, md))
  57. # endif
  58. #
  59. # define BOOST_PP_ENUM_TRAILING_M_1_I(z, n, m, d) , m(z, n, d)
  60. # define BOOST_PP_ENUM_TRAILING_M_2_I(z, n, m, d) , m(z, n, d)
  61. # define BOOST_PP_ENUM_TRAILING_M_3_I(z, n, m, d) , m(z, n, d)
  62. #
  63. # endif