item.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #ifndef BOOST_MPL_VECTOR_AUX_ITEM_HPP_INCLUDED
  2. #define BOOST_MPL_VECTOR_AUX_ITEM_HPP_INCLUDED
  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. #include <boost/mpl/long.hpp>
  14. #include <boost/mpl/void.hpp>
  15. #include <boost/mpl/next_prior.hpp>
  16. #include <boost/mpl/aux_/type_wrapper.hpp>
  17. #include <boost/mpl/aux_/config/typeof.hpp>
  18. #include <boost/mpl/aux_/config/ctps.hpp>
  19. namespace boost { namespace mpl {
  20. #if defined(BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES)
  21. template<
  22. typename T
  23. , typename Base
  24. , int at_front = 0
  25. >
  26. struct v_item
  27. : Base
  28. {
  29. typedef typename Base::upper_bound_ index_;
  30. typedef typename next<index_>::type upper_bound_;
  31. typedef typename next<typename Base::size>::type size;
  32. typedef Base base;
  33. typedef v_item type;
  34. // agurt 10/sep/04: MWCW <= 9.3 workaround here and below; the compiler
  35. // breaks if using declaration comes _before_ the new overload
  36. static aux::type_wrapper<T> item_(index_);
  37. using Base::item_;
  38. };
  39. template<
  40. typename T
  41. , typename Base
  42. >
  43. struct v_item<T,Base,1>
  44. : Base
  45. {
  46. typedef typename prior<typename Base::lower_bound_>::type index_;
  47. typedef index_ lower_bound_;
  48. typedef typename next<typename Base::size>::type size;
  49. typedef Base base;
  50. typedef v_item type;
  51. static aux::type_wrapper<T> item_(index_);
  52. using Base::item_;
  53. };
  54. // "erasure" item
  55. template<
  56. typename Base
  57. , int at_front
  58. >
  59. struct v_mask
  60. : Base
  61. {
  62. typedef typename prior<typename Base::upper_bound_>::type index_;
  63. typedef index_ upper_bound_;
  64. typedef typename prior<typename Base::size>::type size;
  65. typedef Base base;
  66. typedef v_mask type;
  67. static aux::type_wrapper<void_> item_(index_);
  68. using Base::item_;
  69. };
  70. template<
  71. typename Base
  72. >
  73. struct v_mask<Base,1>
  74. : Base
  75. {
  76. typedef typename Base::lower_bound_ index_;
  77. typedef typename next<index_>::type lower_bound_;
  78. typedef typename prior<typename Base::size>::type size;
  79. typedef Base base;
  80. typedef v_mask type;
  81. static aux::type_wrapper<void_> item_(index_);
  82. using Base::item_;
  83. };
  84. #endif // BOOST_MPL_CFG_TYPEOF_BASED_SEQUENCES
  85. }}
  86. #endif // BOOST_MPL_VECTOR_AUX_ITEM_HPP_INCLUDED