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