/Src/Dependencies/Boost/boost/fusion/container/generation/make_map.hpp

http://hadesmem.googlecode.com/ · C++ Header · 106 lines · 79 code · 16 blank · 11 comment · 0 complexity · 8990e6ebb81808240973e5d0ff77b4dc MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2006 Joel de Guzman
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #ifndef BOOST_PP_IS_ITERATING
  7. #if !defined(FUSION_MAKE_MAP_07222005_1247)
  8. #define FUSION_MAKE_MAP_07222005_1247
  9. #include <boost/preprocessor/iterate.hpp>
  10. #include <boost/preprocessor/repetition/enum_params.hpp>
  11. #include <boost/preprocessor/repetition/enum_binary_params.hpp>
  12. #include <boost/preprocessor/repetition/enum_params_with_a_default.hpp>
  13. #include <boost/preprocessor/repetition/repeat_from_to.hpp>
  14. #include <boost/fusion/container/map/map.hpp>
  15. #include <boost/fusion/support/detail/as_fusion_element.hpp>
  16. #include <boost/fusion/support/pair.hpp>
  17. namespace boost { namespace fusion
  18. {
  19. struct void_;
  20. namespace result_of
  21. {
  22. template <
  23. BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
  24. FUSION_MAX_VECTOR_SIZE, typename K, void_)
  25. , BOOST_PP_ENUM_PARAMS_WITH_A_DEFAULT(
  26. FUSION_MAX_VECTOR_SIZE, typename D, void_)
  27. , typename Extra = void_
  28. >
  29. struct make_map;
  30. template <>
  31. struct make_map<>
  32. {
  33. typedef map<> type;
  34. };
  35. }
  36. inline map<>
  37. make_map()
  38. {
  39. return map<>();
  40. }
  41. #define BOOST_FUSION_PAIR(z, n, data) \
  42. fusion::pair< \
  43. BOOST_PP_CAT(K, n) \
  44. , typename detail::as_fusion_element<BOOST_PP_CAT(D, n)>::type>
  45. #define BOOST_FUSION_MAKE_PAIR(z, n, data) \
  46. fusion::make_pair<BOOST_PP_CAT(K, n)>(BOOST_PP_CAT(_, n)) \
  47. #define BOOST_PP_FILENAME_1 <boost/fusion/container/generation/make_map.hpp>
  48. #define BOOST_PP_ITERATION_LIMITS (1, FUSION_MAX_VECTOR_SIZE)
  49. #include BOOST_PP_ITERATE()
  50. #undef BOOST_FUSION_PAIR
  51. #undef BOOST_FUSION_MAKE_PAIR
  52. }}
  53. #endif
  54. #else // defined(BOOST_PP_IS_ITERATING)
  55. ///////////////////////////////////////////////////////////////////////////////
  56. //
  57. // Preprocessor vertical repetition code
  58. //
  59. ///////////////////////////////////////////////////////////////////////////////
  60. #define N BOOST_PP_ITERATION()
  61. namespace result_of
  62. {
  63. template <
  64. BOOST_PP_ENUM_PARAMS(N, typename K)
  65. , BOOST_PP_ENUM_PARAMS(N, typename D)
  66. >
  67. #if defined(BOOST_NO_PARTIAL_SPECIALIZATION_IMPLICIT_DEFAULT_ARGS)
  68. #define TEXT(z, n, text) , text
  69. struct make_map<BOOST_PP_ENUM_PARAMS(N, K), BOOST_PP_ENUM_PARAMS(N, D) BOOST_PP_REPEAT_FROM_TO(N, FUSION_MAX_VECTOR_SIZE, TEXT, void_) BOOST_PP_REPEAT_FROM_TO(BOOST_PP_DEC(N), FUSION_MAX_VECTOR_SIZE, TEXT, void_)>
  70. #undef TEXT
  71. #else
  72. struct make_map<BOOST_PP_ENUM_PARAMS(N, K), BOOST_PP_ENUM_PARAMS(N, D)>
  73. #endif
  74. {
  75. typedef map<BOOST_PP_ENUM(N, BOOST_FUSION_PAIR, _)> type;
  76. };
  77. }
  78. template <
  79. BOOST_PP_ENUM_PARAMS(N, typename K)
  80. , BOOST_PP_ENUM_PARAMS(N, typename D)
  81. >
  82. inline map<BOOST_PP_ENUM(N, BOOST_FUSION_PAIR, _)>
  83. make_map(BOOST_PP_ENUM_BINARY_PARAMS(N, D, const& _))
  84. {
  85. return map<BOOST_PP_ENUM(N, BOOST_FUSION_PAIR, _)>(
  86. BOOST_PP_ENUM(N, BOOST_FUSION_MAKE_PAIR, _));
  87. }
  88. #undef N
  89. #endif // defined(BOOST_PP_IS_ITERATING)