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 9 /// \file views/unordered_multimap_view.hpp 10 /// \brief View of a side of a bimap that is signature compatible with tr1::unordered_multimap. 11 12 #ifndef BOOST_BIMAP_VIEWS_UNOREDERED_MULTIMAP_VIEW_HPP 13 #define BOOST_BIMAP_VIEWS_UNOREDERED_MULTIMAP_VIEW_HPP 14 15 #if defined(_MSC_VER) 16 #pragma once 17 #endif 18 19 #include <boost/config.hpp> 20 21 #include <utility> 22 23 #include <boost/bimap/container_adaptor/unordered_multimap_adaptor.hpp> 24 #include <boost/bimap/detail/non_unique_views_helper.hpp> 25 #include <boost/bimap/support/iterator_type_by.hpp> 26 #include <boost/bimap/detail/map_view_base.hpp> 27 28 namespace boost { 29 namespace bimaps { 30 namespace views { 31 32 /// \brief View of a side of a bimap that is signature compatible with tr1::unordered_multimap. 33 /** 34 35 This class uses container_adaptor and iterator_adaptor to wrapped a index of the 36 multi_index bimap core so it can be used as a tr1::unordered_multimap. 37 38 See also const_unordered_multimap_view. 39 **/ 40 41 template< class Tag, class BimapType > 42 class unordered_multimap_view 43 : 44 public BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR( 45 unordered_multimap_adaptor, 46 Tag,BimapType, 47 local_map_view_iterator,const_local_map_view_iterator 48 ), 49 50 public ::boost::bimaps::detail::map_view_base< 51 unordered_multimap_view<Tag,BimapType>,Tag,BimapType > 52 53 { 54 typedef BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR( 55 unordered_multimap_adaptor, 56 Tag,BimapType, 57 local_map_view_iterator,const_local_map_view_iterator 58 59 ) base_; 60 61 BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(unordered_multimap_view,Tag,BimapType) 62 63 public: 64 65 typedef std::pair< 66 BOOST_DEDUCED_TYPENAME base_::iterator, 67 BOOST_DEDUCED_TYPENAME base_::iterator 68 > range_type; 69 70 typedef std::pair< 71 BOOST_DEDUCED_TYPENAME base_::const_iterator, 72 BOOST_DEDUCED_TYPENAME base_::const_iterator 73 > const_range_type; 74 75 typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type; 76 unordered_multimap_view(BOOST_DEDUCED_TYPENAME base_::base_type & c)77 unordered_multimap_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) 78 : base_(c) {} 79 80 BOOST_BIMAP_NON_UNIQUE_VIEW_INSERT_FUNCTIONS 81 operator =(const unordered_multimap_view & v)82 unordered_multimap_view & operator=(const unordered_multimap_view & v) 83 { 84 this->base() = v.base(); 85 return *this; 86 } 87 }; 88 89 90 } // namespace views 91 92 /*===========================================================================*/ 93 #define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \ 94 typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \ 95 BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME)); 96 /*===========================================================================*/ 97 98 /*===========================================================================*/ 99 #define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \ 100 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,local_iterator) \ 101 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_local_iterator) \ 102 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,range_type) \ 103 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_range_type) \ 104 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,hasher) \ 105 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,key_equal) 106 /*===========================================================================*/ 107 108 namespace detail { 109 110 template< class Tag, class BimapType > 111 struct left_map_view_extra_typedefs< ::boost::bimaps::views::unordered_multimap_view<Tag,BimapType> > 112 { 113 private: typedef ::boost::bimaps::views::unordered_multimap_view<Tag,BimapType> map_view_; 114 public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left) 115 }; 116 117 template< class Tag, class BimapType > 118 struct right_map_view_extra_typedefs< ::boost::bimaps::views::unordered_multimap_view<Tag,BimapType> > 119 { 120 private: typedef ::boost::bimaps::views::unordered_multimap_view<Tag,BimapType> map_view_; 121 public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right) 122 }; 123 124 } // namespace detail 125 126 /*===========================================================================*/ 127 #undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF 128 #undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY 129 /*===========================================================================*/ 130 131 } // namespace bimaps 132 } // namespace boost 133 134 #endif // BOOST_BIMAP_VIEWS_UNOREDERED_MULTIMAP_VIEW_HPP 135 136 137