File indexing completed on 2025-12-16 09:44:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_BIMAP_DETAIL_SET_VIEW_BASE_HPP
0013 #define BOOST_BIMAP_DETAIL_SET_VIEW_BASE_HPP
0014
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018
0019 #include <boost/config.hpp>
0020
0021 #include <boost/bimap/relation/member_at.hpp>
0022 #include <boost/bimap/relation/support/data_extractor.hpp>
0023 #include <boost/bimap/detail/modifier_adaptor.hpp>
0024 #include <boost/bimap/detail/set_view_iterator.hpp>
0025 #include <boost/bimap/relation/support/get_pair_functor.hpp>
0026 #include <boost/bimap/relation/detail/to_mutable_relation_functor.hpp>
0027 #include <boost/bimap/relation/mutant_relation.hpp>
0028 #include <boost/bimap/container_adaptor/support/iterator_facade_converters.hpp>
0029
0030 namespace boost {
0031 namespace bimaps {
0032 namespace detail {
0033
0034 template< class Key, class Value, class KeyToBase >
0035 class set_view_key_to_base
0036 {
0037 public:
0038 const Key operator()( const Value & v ) const
0039 {
0040 return keyToBase( v );
0041 }
0042 private:
0043 KeyToBase keyToBase;
0044 };
0045
0046 template< class MutantRelationStorage, class KeyToBase >
0047 class set_view_key_to_base<MutantRelationStorage,MutantRelationStorage,KeyToBase>
0048 {
0049 typedef BOOST_DEDUCED_TYPENAME MutantRelationStorage::non_mutable_storage non_mutable_storage;
0050 public:
0051 const MutantRelationStorage & operator()( const non_mutable_storage & k ) const
0052 {
0053 return ::boost::bimaps::relation::detail::mutate<MutantRelationStorage>(k);
0054 }
0055 const MutantRelationStorage & operator()( const MutantRelationStorage & k ) const
0056 {
0057 return k;
0058 }
0059 };
0060
0061
0062
0063
0064 #define BOOST_BIMAP_SET_VIEW_CONTAINER_ADAPTOR( \
0065 CONTAINER_ADAPTOR, CORE_INDEX, OTHER_ITER, CONST_OTHER_ITER \
0066 ) \
0067 ::boost::bimaps::container_adaptor::CONTAINER_ADAPTOR \
0068 < \
0069 CORE_INDEX, \
0070 ::boost::bimaps::detail:: \
0071 set_view_iterator< \
0072 BOOST_DEDUCED_TYPENAME CORE_INDEX::iterator >, \
0073 ::boost::bimaps::detail:: \
0074 const_set_view_iterator< \
0075 BOOST_DEDUCED_TYPENAME CORE_INDEX::const_iterator >, \
0076 ::boost::bimaps::detail:: \
0077 set_view_iterator< \
0078 BOOST_DEDUCED_TYPENAME CORE_INDEX::OTHER_ITER >, \
0079 ::boost::bimaps::detail:: \
0080 const_set_view_iterator< \
0081 BOOST_DEDUCED_TYPENAME CORE_INDEX::CONST_OTHER_ITER >, \
0082 ::boost::bimaps::container_adaptor::support::iterator_facade_to_base \
0083 < \
0084 ::boost::bimaps::detail:: set_view_iterator< \
0085 BOOST_DEDUCED_TYPENAME CORE_INDEX::iterator>, \
0086 ::boost::bimaps::detail::const_set_view_iterator< \
0087 BOOST_DEDUCED_TYPENAME CORE_INDEX::const_iterator> \
0088 \
0089 >, \
0090 ::boost::mpl::na, \
0091 ::boost::mpl::na, \
0092 ::boost::bimaps::relation::detail:: \
0093 get_mutable_relation_functor< \
0094 BOOST_DEDUCED_TYPENAME CORE_INDEX::value_type >, \
0095 ::boost::bimaps::relation::support:: \
0096 get_above_view_functor< \
0097 BOOST_DEDUCED_TYPENAME CORE_INDEX::value_type >, \
0098 ::boost::bimaps::detail::set_view_key_to_base< \
0099 BOOST_DEDUCED_TYPENAME CORE_INDEX::key_type, \
0100 BOOST_DEDUCED_TYPENAME CORE_INDEX::value_type, \
0101 BOOST_DEDUCED_TYPENAME CORE_INDEX::key_from_value \
0102 > \
0103 >
0104
0105
0106
0107
0108 #define BOOST_BIMAP_SEQUENCED_SET_VIEW_CONTAINER_ADAPTOR( \
0109 CONTAINER_ADAPTOR, CORE_INDEX, OTHER_ITER, CONST_OTHER_ITER \
0110 ) \
0111 ::boost::bimaps::container_adaptor::CONTAINER_ADAPTOR \
0112 < \
0113 CORE_INDEX, \
0114 ::boost::bimaps::detail:: \
0115 set_view_iterator< \
0116 BOOST_DEDUCED_TYPENAME CORE_INDEX::iterator >, \
0117 ::boost::bimaps::detail:: \
0118 const_set_view_iterator< \
0119 BOOST_DEDUCED_TYPENAME CORE_INDEX::const_iterator >, \
0120 ::boost::bimaps::detail:: \
0121 set_view_iterator< \
0122 BOOST_DEDUCED_TYPENAME CORE_INDEX::OTHER_ITER >, \
0123 ::boost::bimaps::detail:: \
0124 const_set_view_iterator< \
0125 BOOST_DEDUCED_TYPENAME CORE_INDEX::CONST_OTHER_ITER >, \
0126 ::boost::bimaps::container_adaptor::support::iterator_facade_to_base \
0127 < \
0128 ::boost::bimaps::detail:: set_view_iterator< \
0129 BOOST_DEDUCED_TYPENAME CORE_INDEX::iterator>, \
0130 ::boost::bimaps::detail::const_set_view_iterator< \
0131 BOOST_DEDUCED_TYPENAME CORE_INDEX::const_iterator> \
0132 \
0133 >, \
0134 ::boost::mpl::na, \
0135 ::boost::mpl::na, \
0136 ::boost::bimaps::relation::detail:: \
0137 get_mutable_relation_functor< \
0138 BOOST_DEDUCED_TYPENAME CORE_INDEX::value_type >, \
0139 ::boost::bimaps::relation::support:: \
0140 get_above_view_functor< \
0141 BOOST_DEDUCED_TYPENAME CORE_INDEX::value_type > \
0142 >
0143
0144
0145
0146 #if defined(BOOST_MSVC)
0147
0148 #define BOOST_BIMAP_SET_VIEW_BASE_FRIEND(TYPE,INDEX_TYPE) \
0149 typedef ::boost::bimaps::detail::set_view_base< \
0150 TYPE< INDEX_TYPE >, INDEX_TYPE > template_class_friend; \
0151 friend class template_class_friend;
0152
0153 #else
0154
0155 #define BOOST_BIMAP_SET_VIEW_BASE_FRIEND(TYPE,INDEX_TYPE) \
0156 friend class ::boost::bimaps::detail::set_view_base< \
0157 TYPE< INDEX_TYPE >, INDEX_TYPE >;
0158
0159 #endif
0160
0161
0162
0163
0164 template< class Derived, class Index >
0165 class set_view_base
0166 {
0167 typedef ::boost::bimaps::container_adaptor::support::
0168 iterator_facade_to_base
0169 <
0170 ::boost::bimaps::detail::
0171 set_view_iterator<BOOST_DEDUCED_TYPENAME Index:: iterator>,
0172 ::boost::bimaps::detail::
0173 const_set_view_iterator<BOOST_DEDUCED_TYPENAME Index::const_iterator>
0174
0175 > iterator_to_base_;
0176
0177 typedef BOOST_DEDUCED_TYPENAME Index::value_type::left_value_type left_type_;
0178
0179 typedef BOOST_DEDUCED_TYPENAME Index::value_type::right_value_type right_type_;
0180
0181 typedef BOOST_DEDUCED_TYPENAME Index::value_type value_type_;
0182
0183 typedef ::boost::bimaps::detail::
0184 set_view_iterator<BOOST_DEDUCED_TYPENAME Index::iterator> iterator_;
0185
0186 public:
0187
0188 bool replace(iterator_ position,
0189 const value_type_ & x)
0190 {
0191 return derived().base().replace(
0192 derived().template functor<iterator_to_base_>()(position),x
0193 );
0194 }
0195
0196 template< class CompatibleLeftType >
0197 bool replace_left(iterator_ position,
0198 const CompatibleLeftType & l)
0199 {
0200 return derived().base().replace(
0201 derived().template functor<iterator_to_base_>()(position),
0202 ::boost::bimaps::relation::detail::copy_with_left_replaced(*position,l)
0203 );
0204 }
0205
0206 template< class CompatibleRightType >
0207 bool replace_right(iterator_ position,
0208 const CompatibleRightType & r)
0209 {
0210 return derived().base().replace(
0211 derived().template functor<iterator_to_base_>()(position),
0212 ::boost::bimaps::relation::detail::copy_with_right_replaced(*position,r)
0213 );
0214 }
0215
0216
0217
0218
0219
0220
0221
0222
0223
0224
0225
0226
0227
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276
0277
0278
0279
0280
0281
0282
0283
0284
0285
0286
0287
0288
0289
0290
0291
0292
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303
0304
0305
0306 protected:
0307
0308 typedef set_view_base set_view_base_;
0309
0310 private:
0311
0312
0313
0314 Derived& derived()
0315 {
0316 return *static_cast<Derived*>(this);
0317 }
0318
0319 Derived const& derived() const
0320 {
0321 return *static_cast<Derived const*>(this);
0322 }
0323 };
0324
0325
0326
0327 }
0328 }
0329 }
0330
0331 #endif