numbered.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // NO INCLUDE GUARDS, THE HEADER IS INTENDED FOR MULTIPLE INCLUSION
  2. #if !defined(BOOST_PP_IS_ITERATING)
  3. // Copyright Aleksey Gurtovoy 2000-2004
  4. //
  5. // Distributed under the Boost Software License, Version 1.0.
  6. // (See accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //
  9. // See http://www.boost.org/libs/mpl for documentation.
  10. // $Id$
  11. // $Date$
  12. // $Revision$
  13. #else
  14. #include <boost/mpl/aux_/config/typeof.hpp>
  15. #include <boost/mpl/aux_/config/ctps.hpp>
  16. #include <boost/preprocessor/enum_params.hpp>
  17. #include <boost/preprocessor/dec.hpp>
  18. #include <boost/preprocessor/cat.hpp>
  19. #define i_ BOOST_PP_FRAME_ITERATION(1)
  20. # define AUX778076_MAP_TAIL(map, i_, P) \
  21. BOOST_PP_CAT(map,i_)< \
  22. BOOST_PP_ENUM_PARAMS(i_, P) \
  23. > \
  24. /**/
  25. #if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
  26. template<
  27. BOOST_PP_ENUM_PARAMS(i_, typename P)
  28. >
  29. struct BOOST_PP_CAT(map,i_)
  30. : m_item<
  31. typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::first
  32. , typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::second
  33. , AUX778076_MAP_TAIL(map,BOOST_PP_DEC(i_),P)
  34. >
  35. {
  36. typedef BOOST_PP_CAT(map,i_) type;
  37. };
  38. #else // "brute force" implementation
  39. # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  40. template< typename Map>
  41. struct m_at<Map,BOOST_PP_DEC(i_)>
  42. {
  43. typedef typename Map::BOOST_PP_CAT(item,BOOST_PP_DEC(i_)) type;
  44. };
  45. template< typename Key, typename T, typename Base >
  46. struct m_item<i_,Key,T,Base>
  47. : m_item_<Key,T,Base>
  48. {
  49. typedef pair<Key,T> BOOST_PP_CAT(item,BOOST_PP_DEC(i_));
  50. };
  51. # else
  52. template<>
  53. struct m_at_impl<BOOST_PP_DEC(i_)>
  54. {
  55. template< typename Map > struct result_
  56. {
  57. typedef typename Map::BOOST_PP_CAT(item,BOOST_PP_DEC(i_)) type;
  58. };
  59. };
  60. template<>
  61. struct m_item_impl<i_>
  62. {
  63. template< typename Key, typename T, typename Base > struct result_
  64. : m_item_<Key,T,Base>
  65. {
  66. typedef pair<Key,T> BOOST_PP_CAT(item,BOOST_PP_DEC(i_));
  67. };
  68. };
  69. # endif
  70. template<
  71. BOOST_PP_ENUM_PARAMS(i_, typename P)
  72. >
  73. struct BOOST_PP_CAT(map,i_)
  74. : m_item<
  75. i_
  76. , typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::first
  77. , typename BOOST_PP_CAT(P,BOOST_PP_DEC(i_))::second
  78. , AUX778076_MAP_TAIL(map,BOOST_PP_DEC(i_),P)
  79. >
  80. {
  81. typedef BOOST_PP_CAT(map,i_) type;
  82. };
  83. #endif // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
  84. # undef AUX778076_MAP_TAIL
  85. #undef i_
  86. #endif // BOOST_PP_IS_ITERATING