item.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #ifndef BOOST_MPL_MAP_AUX_ITEM_HPP_INCLUDED
  2. #define BOOST_MPL_MAP_AUX_ITEM_HPP_INCLUDED
  3. // Copyright Aleksey Gurtovoy 2003-2004
  4. // Copyright David Abrahams 2003-2004
  5. //
  6. // Distributed under the Boost Software License, Version 1.0.
  7. // (See accompanying file LICENSE_1_0.txt or copy at
  8. // http://www.boost.org/LICENSE_1_0.txt)
  9. //
  10. // See http://www.boost.org/libs/mpl for documentation.
  11. // $Id$
  12. // $Date$
  13. // $Revision$
  14. #include <boost/mpl/void.hpp>
  15. #include <boost/mpl/pair.hpp>
  16. #include <boost/mpl/long.hpp>
  17. #include <boost/mpl/next.hpp>
  18. #include <boost/mpl/prior.hpp>
  19. #include <boost/mpl/map/aux_/map0.hpp>
  20. #include <boost/mpl/aux_/order_impl.hpp>
  21. #include <boost/mpl/aux_/yes_no.hpp>
  22. #include <boost/mpl/aux_/type_wrapper.hpp>
  23. #include <boost/mpl/aux_/config/arrays.hpp>
  24. #include <boost/mpl/aux_/config/typeof.hpp>
  25. #include <boost/mpl/aux_/config/ctps.hpp>
  26. namespace boost { namespace mpl {
  27. #if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
  28. template< typename Key, typename T, typename Base >
  29. struct m_item
  30. : Base
  31. {
  32. typedef Key key_;
  33. typedef pair<Key,T> item;
  34. typedef Base base;
  35. typedef m_item type;
  36. typedef typename next< typename Base::size >::type size;
  37. typedef typename next< typename Base::order >::type order;
  38. #if defined(BOOST_MPL_CFG_NO_DEPENDENT_ARRAY_TYPES)
  39. typedef typename aux::weighted_tag<BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value>::type order_tag_;
  40. #else
  41. typedef char (&order_tag_)[BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value];
  42. #endif
  43. BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<T>, VALUE_BY_KEY, m_item, aux::type_wrapper<Key>* );
  44. BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<item>, ITEM_BY_ORDER, m_item, order* );
  45. BOOST_MPL_AUX_MAP_OVERLOAD( order_tag_, ORDER_BY_KEY, m_item, aux::type_wrapper<Key>* );
  46. };
  47. template< typename Key, typename Base >
  48. struct m_mask
  49. : Base
  50. {
  51. typedef void_ key_;
  52. typedef Base base;
  53. typedef m_mask type;
  54. typedef typename prior< typename Base::size >::type size;
  55. typedef typename x_order_impl<Base,Key>::type key_order_;
  56. BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<void_>, VALUE_BY_KEY, m_mask, aux::type_wrapper<Key>* );
  57. BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<void_>, ITEM_BY_ORDER, m_mask, key_order_* );
  58. };
  59. #else // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
  60. # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  61. template< long n, typename Key, typename T, typename Base >
  62. struct m_item;
  63. # else
  64. template< long n >
  65. struct m_item_impl
  66. {
  67. template< typename Key, typename T, typename Base >
  68. struct result_;
  69. };
  70. template< long n, typename Key, typename T, typename Base >
  71. struct m_item
  72. : m_item_impl<n>::result_<Key,T,Base>
  73. {
  74. };
  75. # endif
  76. template< typename Key, typename T, typename Base >
  77. struct m_item_
  78. : Base
  79. {
  80. typedef Key key_;
  81. typedef Base base;
  82. typedef m_item_ type;
  83. typedef typename next< typename Base::size >::type size;
  84. typedef typename next< typename Base::order >::type order;
  85. #if defined(BOOST_MPL_CFG_NO_DEPENDENT_ARRAY_TYPES)
  86. typedef typename aux::weighted_tag<BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value>::type order_tag_;
  87. #else
  88. typedef char (&order_tag_)[BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value];
  89. #endif
  90. BOOST_MPL_AUX_MAP_OVERLOAD( order_tag_, ORDER_BY_KEY, m_item_, aux::type_wrapper<Key>* );
  91. };
  92. template< typename Key, typename Base >
  93. struct m_mask
  94. : Base
  95. {
  96. typedef void_ key_;
  97. typedef Base base;
  98. typedef m_mask type;
  99. typedef typename prior< typename Base::size >::type size;
  100. typedef typename x_order_impl<Base,Key>::type key_order_;
  101. BOOST_MPL_AUX_MAP_OVERLOAD( aux::no_tag, ORDER_BY_KEY, m_mask, aux::type_wrapper<Key>* );
  102. BOOST_MPL_AUX_MAP_OVERLOAD( aux::yes_tag, IS_MASKED, m_mask, key_order_* );
  103. };
  104. #endif // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
  105. }}
  106. #endif // BOOST_MPL_MAP_AUX_ITEM_HPP_INCLUDED