3 // Copyright (c) 2006-2007 Matias Capeletto
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)
9 /// \file views/list_map_view.hpp
10 /// \brief View of a side of a bimap.
12 #ifndef BOOST_BIMAP_VIEWS_LIST_MAP_VIEW_HPP
13 #define BOOST_BIMAP_VIEWS_LIST_MAP_VIEW_HPP
15 #if defined(_MSC_VER) && (_MSC_VER>=1200)
19 #include <boost/config.hpp>
21 #include <boost/bimap/container_adaptor/list_map_adaptor.hpp>
22 #include <boost/bimap/relation/support/pair_by.hpp>
23 #include <boost/bimap/support/iterator_type_by.hpp>
24 #include <boost/bimap/detail/map_view_base.hpp>
25 #include <boost/bimap/relation/support/data_extractor.hpp>
26 #include <boost/bimap/relation/detail/to_mutable_relation_functor.hpp>
32 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
34 template< class Tag, class BimapType >
35 struct list_map_view_base
37 typedef ::boost::bimaps::container_adaptor::list_map_adaptor
39 BOOST_DEDUCED_TYPENAME BimapType::core_type::BOOST_NESTED_TEMPLATE index<Tag>::type,
40 BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
41 iterator_type_by<Tag,BimapType>::type,
42 BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
43 const_iterator_type_by<Tag,BimapType>::type,
44 BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
45 reverse_iterator_type_by<Tag,BimapType>::type,
46 BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
47 const_reverse_iterator_type_by<Tag,BimapType>::type,
48 ::boost::bimaps::container_adaptor::support::iterator_facade_to_base
50 BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
51 iterator_type_by<Tag,BimapType>::type,
52 BOOST_DEDUCED_TYPENAME ::boost::bimaps::support::
53 const_iterator_type_by<Tag,BimapType>::type
58 ::boost::bimaps::relation::detail::
59 pair_to_relation_functor<Tag, BOOST_DEDUCED_TYPENAME BimapType::relation >,
60 ::boost::bimaps::relation::support::
61 get_pair_functor<Tag, BOOST_DEDUCED_TYPENAME BimapType::relation >,
63 BOOST_DEDUCED_TYPENAME ::boost::bimaps::relation::support::data_extractor
66 BOOST_DEDUCED_TYPENAME BimapType::relation
73 #endif // BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
75 /// \brief View of a side of a bimap.
78 This class uses container_adaptor and iterator_adaptor to wrapped a index of the
79 multi_index bimap core.
81 See also const_list_map_view.
83 template< class Tag, class BimapType >
86 public list_map_view_base<Tag,BimapType>::type,
87 public ::boost::bimaps::detail::
88 map_view_base< list_map_view<Tag,BimapType>,Tag,BimapType >
91 typedef BOOST_DEDUCED_TYPENAME list_map_view_base<Tag,BimapType>::type base_;
93 BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(list_map_view,Tag,BimapType)
97 typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type;
99 list_map_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) :
102 list_map_view & operator=(const list_map_view & v)
104 this->base() = v.base();
108 BOOST_BIMAP_VIEW_ASSIGN_IMPLEMENTATION(base_)
110 BOOST_BIMAP_VIEW_FRONT_BACK_IMPLEMENTATION(base_)
112 // Rearrange Operations
114 void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
115 BOOST_DEDUCED_TYPENAME base_::iterator i)
117 this->base().relocate(
118 this->template functor<
119 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
120 this->template functor<
121 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(i)
125 void relocate(BOOST_DEDUCED_TYPENAME base_::iterator position,
126 BOOST_DEDUCED_TYPENAME base_::iterator first,
127 BOOST_DEDUCED_TYPENAME base_::iterator last)
129 this->base().relocate(
130 this->template functor<
131 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(position),
132 this->template functor<
133 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(first),
134 this->template functor<
135 BOOST_DEDUCED_TYPENAME base_::iterator_to_base>()(last)
143 /*===========================================================================*/
144 #define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \
145 typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \
146 BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME));
147 /*===========================================================================*/
149 /*===========================================================================*/
150 #define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \
151 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,reverse_iterator) \
152 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_reverse_iterator) \
153 /*===========================================================================*/
157 template< class Tag, class BimapType >
158 struct left_map_view_extra_typedefs< ::boost::bimaps::views::list_map_view<Tag,BimapType> >
160 private: typedef ::boost::bimaps::views::list_map_view<Tag,BimapType> map_view_;
161 public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left)
164 template< class Tag, class BimapType >
165 struct right_map_view_extra_typedefs< ::boost::bimaps::views::list_map_view<Tag,BimapType> >
167 private: typedef ::boost::bimaps::views::list_map_view<Tag,BimapType> map_view_;
168 public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right)
171 } // namespace detail
173 /*===========================================================================*/
174 #undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF
175 #undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY
176 /*===========================================================================*/
178 } // namespace bimaps
181 #endif // BOOST_BIMAP_VIEWS_LIST_MAP_VIEW_HPP