enum.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # /* Copyright (C) 2001
  2. # * Housemarque Oy
  3. # * http://www.housemarque.com
  4. # *
  5. # * Distributed under the Boost Software License, Version 1.0. (See
  6. # * accompanying file LICENSE_1_0.txt or copy at
  7. # * http://www.boost.org/LICENSE_1_0.txt)
  8. # */
  9. #
  10. # /* Revised by Paul Mensonides (2002) */
  11. #
  12. # /* See http://www.boost.org for most recent version. */
  13. #
  14. # ifndef BOOST_PREPROCESSOR_LIST_ENUM_HPP
  15. # define BOOST_PREPROCESSOR_LIST_ENUM_HPP
  16. #
  17. # include <boost/preprocessor/config/config.hpp>
  18. # include <boost/preprocessor/control/iif.hpp>
  19. # include <boost/preprocessor/list/adt.hpp>
  20. # include <boost/preprocessor/list/for_each_i.hpp>
  21. # include <boost/preprocessor/punctuation/comma_if.hpp>
  22. # include <boost/preprocessor/variadic/has_opt.hpp>
  23. #
  24. # /* BOOST_PP_LIST_ENUM */
  25. #
  26. # if BOOST_PP_VARIADIC_HAS_OPT()
  27. # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
  28. # define BOOST_PP_LIST_ENUM_NOT_EMPTY(list) BOOST_PP_LIST_FOR_EACH_I(BOOST_PP_LIST_ENUM_O, BOOST_PP_NIL, list)
  29. # else
  30. # define BOOST_PP_LIST_ENUM_NOT_EMPTY(list) BOOST_PP_LIST_ENUM_I(list)
  31. # define BOOST_PP_LIST_ENUM_I(list) BOOST_PP_LIST_FOR_EACH_I(BOOST_PP_LIST_ENUM_O, BOOST_PP_NIL, list)
  32. # endif
  33. # define BOOST_PP_LIST_ENUM_EMPTY(list)
  34. # define BOOST_PP_LIST_ENUM(list) BOOST_PP_IIF(BOOST_PP_LIST_IS_NIL(list),BOOST_PP_LIST_ENUM_EMPTY,BOOST_PP_LIST_ENUM_NOT_EMPTY)(list)
  35. # elif ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
  36. # define BOOST_PP_LIST_ENUM(list) BOOST_PP_LIST_FOR_EACH_I(BOOST_PP_LIST_ENUM_O, BOOST_PP_NIL, list)
  37. # else
  38. # define BOOST_PP_LIST_ENUM(list) BOOST_PP_LIST_ENUM_I(list)
  39. # define BOOST_PP_LIST_ENUM_I(list) BOOST_PP_LIST_FOR_EACH_I(BOOST_PP_LIST_ENUM_O, BOOST_PP_NIL, list)
  40. # endif
  41. #
  42. # define BOOST_PP_LIST_ENUM_O(r, _, i, elem) BOOST_PP_COMMA_IF(i) elem
  43. #
  44. # /* BOOST_PP_LIST_ENUM_R */
  45. #
  46. # if ~BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_EDG()
  47. # define BOOST_PP_LIST_ENUM_R(r, list) BOOST_PP_LIST_FOR_EACH_I_R(r, BOOST_PP_LIST_ENUM_O, BOOST_PP_NIL, list)
  48. # else
  49. # define BOOST_PP_LIST_ENUM_R(r, list) BOOST_PP_LIST_ENUM_R_I(r, list)
  50. # define BOOST_PP_LIST_ENUM_R_I(r, list) BOOST_PP_LIST_FOR_EACH_I_R(r, BOOST_PP_LIST_ENUM_O, BOOST_PP_NIL, list)
  51. # endif
  52. #
  53. # endif