File indexing completed on 2025-12-16 09:44:10
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_BIMAP_VIEWS_MAP_VIEW_HPP
0013 #define BOOST_BIMAP_VIEWS_MAP_VIEW_HPP
0014
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018
0019 #include <boost/config.hpp>
0020
0021 #include <boost/bimap/container_adaptor/map_adaptor.hpp>
0022 #include <boost/bimap/detail/map_view_base.hpp>
0023
0024 namespace boost {
0025 namespace bimaps {
0026 namespace views {
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037 template< class Tag, class BimapType >
0038 class map_view
0039 :
0040 public BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
0041 map_adaptor,
0042 Tag,BimapType,
0043 reverse_map_view_iterator,const_reverse_map_view_iterator
0044 ),
0045 public ::boost::bimaps::detail::
0046 map_view_base< map_view<Tag,BimapType>,Tag,BimapType >,
0047 public ::boost::bimaps::detail::
0048 unique_map_view_access< map_view<Tag,BimapType>, Tag, BimapType>::type
0049 {
0050 typedef BOOST_BIMAP_MAP_VIEW_CONTAINER_ADAPTOR(
0051 map_adaptor,
0052 Tag,BimapType,
0053 reverse_map_view_iterator,const_reverse_map_view_iterator
0054
0055 ) base_;
0056
0057 BOOST_BIMAP_MAP_VIEW_BASE_FRIEND(map_view,Tag,BimapType)
0058
0059 typedef BOOST_DEDUCED_TYPENAME ::boost::bimaps::detail::
0060 unique_map_view_access<
0061 map_view<Tag,BimapType>, Tag, BimapType
0062
0063 >::type unique_map_view_access_;
0064
0065 public:
0066
0067 typedef BOOST_DEDUCED_TYPENAME base_::value_type::info_type info_type;
0068
0069 map_view(BOOST_DEDUCED_TYPENAME base_::base_type & c) : base_(c) {}
0070
0071 using unique_map_view_access_::at;
0072 using unique_map_view_access_::operator[];
0073
0074 BOOST_BIMAP_MAP_VIEW_RANGE_IMPLEMENTATION(base_)
0075
0076 map_view & operator=(const map_view & v)
0077 {
0078 this->base() = v.base();
0079 return *this;
0080 }
0081
0082
0083
0084
0085 template< class CompatibleKey >
0086 const info_type & info_at(const CompatibleKey& k) const
0087 {
0088 BOOST_DEDUCED_TYPENAME base_::const_iterator iter = this->find(k);
0089 if( iter == this->end() )
0090 {
0091 ::boost::throw_exception(
0092 std::out_of_range("bimap<>: invalid key")
0093 );
0094 }
0095 return iter->info;
0096 }
0097
0098 template< class CompatibleKey >
0099 info_type & info_at(const CompatibleKey& k)
0100 {
0101 BOOST_DEDUCED_TYPENAME base_::iterator iter = this->find(k);
0102 if( iter == this->end() )
0103 {
0104 ::boost::throw_exception(
0105 std::out_of_range("bimap<>: invalid key")
0106 );
0107 }
0108 return iter->info;
0109 }
0110 };
0111
0112 }
0113
0114
0115 #define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,TYPENAME) \
0116 typedef BOOST_DEDUCED_TYPENAME MAP_VIEW::TYPENAME \
0117 BOOST_PP_CAT(SIDE,BOOST_PP_CAT(_,TYPENAME));
0118
0119
0120
0121 #define BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(MAP_VIEW,SIDE) \
0122 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,reverse_iterator) \
0123 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_reverse_iterator) \
0124 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,range_type) \
0125 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,const_range_type) \
0126 BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF(MAP_VIEW,SIDE,key_compare)
0127
0128
0129 namespace detail {
0130
0131 template< class Tag, class BimapType >
0132 struct left_map_view_extra_typedefs< ::boost::bimaps::views::map_view<Tag,BimapType> >
0133 {
0134 private: typedef ::boost::bimaps::views::map_view<Tag,BimapType> map_view_;
0135 public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,left)
0136 };
0137
0138 template< class Tag, class BimapType >
0139 struct right_map_view_extra_typedefs< ::boost::bimaps::views::map_view<Tag,BimapType> >
0140 {
0141 private: typedef ::boost::bimaps::views::map_view<Tag,BimapType> map_view_;
0142 public : BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY(map_view_,right)
0143 };
0144
0145 }
0146
0147
0148 #undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEF
0149 #undef BOOST_BIMAP_MAP_VIEW_EXTRA_TYPEDEFS_BODY
0150
0151
0152 }
0153 }
0154
0155 #endif
0156