item.hpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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: item.hpp 49267 2008-10-11 06:19:02Z agurtovoy $
  12. // $Date: 2008-10-11 02:19:02 -0400 (Sat, 11 Oct 2008) $
  13. // $Revision: 49267 $
  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 typename next< typename Base::size >::type size;
  36. typedef typename next< typename Base::order >::type order;
  37. #if defined(BOOST_MPL_CFG_NO_DEPENDENT_ARRAY_TYPES)
  38. typedef typename aux::weighted_tag<BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value>::type order_tag_;
  39. #else
  40. typedef char (&order_tag_)[BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value];
  41. #endif
  42. BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<T>, VALUE_BY_KEY, m_item, aux::type_wrapper<Key>* );
  43. BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<item>, ITEM_BY_ORDER, m_item, order* );
  44. BOOST_MPL_AUX_MAP_OVERLOAD( order_tag_, ORDER_BY_KEY, m_item, aux::type_wrapper<Key>* );
  45. };
  46. template< typename Key, typename Base >
  47. struct m_mask
  48. : Base
  49. {
  50. typedef void_ key_;
  51. typedef Base base;
  52. typedef typename prior< typename Base::size >::type size;
  53. typedef typename x_order_impl<Base,Key>::type key_order_;
  54. BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<void_>, VALUE_BY_KEY, m_mask, aux::type_wrapper<Key>* );
  55. BOOST_MPL_AUX_MAP_OVERLOAD( aux::type_wrapper<void_>, ITEM_BY_ORDER, m_mask, key_order_* );
  56. };
  57. #else // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
  58. # if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  59. template< long n, typename Key, typename T, typename Base >
  60. struct m_item;
  61. # else
  62. template< long n >
  63. struct m_item_impl
  64. {
  65. template< typename Key, typename T, typename Base >
  66. struct result_;
  67. };
  68. template< long n, typename Key, typename T, typename Base >
  69. struct m_item
  70. : m_item_impl<n>::result_<Key,T,Base>
  71. {
  72. };
  73. # endif
  74. template< typename Key, typename T, typename Base >
  75. struct m_item_
  76. : Base
  77. {
  78. typedef Key key_;
  79. typedef Base base;
  80. typedef m_item_ type;
  81. typedef typename next< typename Base::size >::type size;
  82. typedef typename next< typename Base::order >::type order;
  83. #if defined(BOOST_MPL_CFG_NO_DEPENDENT_ARRAY_TYPES)
  84. typedef typename aux::weighted_tag<BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value>::type order_tag_;
  85. #else
  86. typedef char (&order_tag_)[BOOST_MPL_AUX_MSVC_VALUE_WKND(order)::value];
  87. #endif
  88. BOOST_MPL_AUX_MAP_OVERLOAD( order_tag_, ORDER_BY_KEY, m_item_, aux::type_wrapper<Key>* );
  89. };
  90. template< typename Key, typename Base >
  91. struct m_mask
  92. : Base
  93. {
  94. typedef void_ key_;
  95. typedef Base base;
  96. typedef typename prior< typename Base::size >::type size;
  97. typedef typename x_order_impl<Base,Key>::type key_order_;
  98. BOOST_MPL_AUX_MAP_OVERLOAD( aux::no_tag, ORDER_BY_KEY, m_mask, aux::type_wrapper<Key>* );
  99. BOOST_MPL_AUX_MAP_OVERLOAD( aux::yes_tag, IS_MASKED, m_mask, key_order_* );
  100. };
  101. #endif // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
  102. }}
  103. #endif // BOOST_MPL_MAP_AUX_ITEM_HPP_INCLUDED