multimap_view.hpp 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // Boost.Bimap
  2. //
  3. // Copyright (c) 2006-2007 Matias Capeletto
  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. /// \file views/multimap_view.hpp
  9. /// \brief View of a side of a bimap that is signature compatible with std::multimap.
  10. #ifndef BOOST_BIMAP_VIEWS_MULTIMAP_VIEW_HPP
  11. #define BOOST_BIMAP_VIEWS_MULTIMAP_VIEW_HPP
  12. #if defined(_MSC_VER)
  13. #pragma once
  14. #endif
  15. #include <boost/config.hpp>
  16. #include <boost/bimap/container_adaptor/multimap_adaptor.hpp>
  17. #include <boost/bimap/detail/non_unique_views_helper.hpp>
  18. #include <boost/bimap/support/iterator_type_by.hpp>
  19. #include <boost/bimap/detail/map_view_base.hpp>
  20. namespace boost {
  21. namespace bimaps {
  22. namespace views {
  23. /// \brief View of a side of a bimap that is signature compatible with std::multimap.
  24. /**
  25. This class uses container_adaptor and iterator_adaptor to wrapped a index of the
  26. multi_index bimap core so it can be used as a std::multimap.
  27. See also const_multimap_view.
  28. **/
  29. template< class Tag, class BimapType >
  30. class multimap_view
  31. :
  32. public BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
  33. multimap_adaptor,
  34. Tag,BimapType,
  35. reverse_map_view_iterator,const_reverse_map_view_iterator
  36. ),
  37. public ::boost::bimaps::detail::
  38. map_view_base< multimap_view<Tag,BimapType>,Tag,BimapType >
  39. {
  40. typedef BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
  41. multimap_adaptor,
  42. Tag,BimapType,
  43. reverse_map_view_iterator,const_reverse_map_view_iterator
  44. ) base_;
  45. BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(multimap_view,Tag,BimapType)
  46. public:
  47. typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type;
  48. multimap_view(BOOST_DEDUCED_TYPENAME base_::base_type & c)
  49. : base_(c) {}
  50. BOOST_BIMAP_MAP_VIEW_RANGE_IMPLEMENTATION(base_)
  51. multimap_view & operator=(const multimap_view & v)
  52. {
  53. this->base() = v.base();
  54. return *this;
  55. }
  56. BOOST_BIMAP_NON_UNIQUE_VIEW_INSERT_FUNCTIONS
  57. };
  58. } // namespace views
  59. /*===========================================================================*/
  60. #define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \
  61. typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \
  62. BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME));
  63. /*===========================================================================*/
  64. /*===========================================================================*/
  65. #define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \
  66. BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,reverse_iterator) \
  67. BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_reverse_iterator) \
  68. BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,range_type) \
  69. BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_range_type) \
  70. BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,key_compare)
  71. /*===========================================================================*/
  72. namespace detail {
  73. template< class Tag, class BimapType >
  74. struct left_map_view_extra_typedefs< ::boost::bimaps::views::multimap_view<Tag,BimapType> >
  75. {
  76. private: typedef ::boost::bimaps::views::multimap_view<Tag,BimapType> map_view_;
  77. public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left)
  78. };
  79. template< class Tag, class BimapType >
  80. struct right_map_view_extra_typedefs< ::boost::bimaps::views::multimap_view<Tag,BimapType> >
  81. {
  82. private: typedef ::boost::bimaps::views::multimap_view<Tag,BimapType> map_view_;
  83. public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right)
  84. };
  85. } // namespace detail
  86. /*===========================================================================*/
  87. #undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF
  88. #undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY
  89. /*===========================================================================*/
  90. } // namespace bimaps
  91. } // namespace boost
  92. #endif // BOOST_BIMAP_VIEWS_MAP_VIEW_HPP