File indexing completed on 2025-01-30 09:34:15
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_LIST_MAP_ADAPTOR_HPP
0013 #define BOOST_BIMAP_CONTAINER_ADAPTOR_LIST_MAP_ADAPTOR_HPP
0014
0015 #if defined(_MSC_VER)
0016 #pragma once
0017 #endif
0018
0019 #include <boost/config.hpp>
0020
0021 #include <boost/mpl/list.hpp>
0022 #include <boost/mpl/push_front.hpp>
0023
0024 #include <boost/bimap/container_adaptor/list_adaptor.hpp>
0025 #include <boost/bimap/container_adaptor/detail/identity_converters.hpp>
0026 #include <boost/bimap/container_adaptor/detail/key_extractor.hpp>
0027 #include <boost/bimap/container_adaptor/detail/comparison_adaptor.hpp>
0028 #include <boost/mpl/vector.hpp>
0029 #include <boost/mpl/aux_/na.hpp>
0030 #include <boost/mpl/if.hpp>
0031
0032 namespace boost {
0033 namespace bimaps {
0034 namespace container_adaptor {
0035
0036 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0037
0038 template
0039 <
0040 class Base, class Iterator, class ConstIterator,
0041 class ReverseIterator, class ConstReverseIterator,
0042 class IteratorToBaseConverter, class IteratorFromBaseConverter,
0043 class ReverseIteratorFromBaseConverter,
0044 class ValueToBaseConverter, class ValueFromBaseConverter,
0045 class KeyFromBaseValueConverter,
0046 class FunctorsFromDerivedClasses
0047 >
0048 struct list_map_adaptor_base
0049 {
0050 typedef list_adaptor
0051 <
0052 Base,
0053
0054 Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
0055
0056 IteratorToBaseConverter, IteratorFromBaseConverter,
0057
0058 ReverseIteratorFromBaseConverter,
0059
0060 ValueToBaseConverter, ValueFromBaseConverter,
0061
0062 BOOST_DEDUCED_TYPENAME mpl::push_front<
0063
0064 FunctorsFromDerivedClasses,
0065
0066 BOOST_DEDUCED_TYPENAME mpl::if_< ::boost::mpl::is_na<KeyFromBaseValueConverter>,
0067
0068 detail::key_from_pair_extractor
0069 <
0070 BOOST_DEDUCED_TYPENAME Iterator::value_type
0071 >,
0072
0073
0074
0075 KeyFromBaseValueConverter
0076
0077
0078 >::type
0079
0080 >::type
0081
0082 > type;
0083 };
0084
0085 #endif
0086
0087
0088
0089 template
0090 <
0091 class Base,
0092
0093 class Iterator,
0094 class ConstIterator,
0095 class ReverseIterator,
0096 class ConstReverseIterator,
0097
0098 class IteratorToBaseConverter = ::boost::mpl::na,
0099 class IteratorFromBaseConverter = ::boost::mpl::na,
0100 class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
0101 class ValueToBaseConverter = ::boost::mpl::na,
0102 class ValueFromBaseConverter = ::boost::mpl::na,
0103 class KeyFromBaseValueConverter = ::boost::mpl::na,
0104
0105 class FunctorsFromDerivedClasses = mpl::vector<>
0106 >
0107 class list_map_adaptor :
0108
0109 public list_map_adaptor_base
0110 <
0111 Base, Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
0112 IteratorToBaseConverter, IteratorFromBaseConverter,
0113 ReverseIteratorFromBaseConverter,
0114 ValueToBaseConverter, ValueFromBaseConverter,
0115 KeyFromBaseValueConverter,
0116 FunctorsFromDerivedClasses
0117
0118 >::type
0119 {
0120 typedef BOOST_DEDUCED_TYPENAME list_map_adaptor_base
0121 <
0122 Base, Iterator, ConstIterator, ReverseIterator, ConstReverseIterator,
0123 IteratorToBaseConverter, IteratorFromBaseConverter,
0124 ReverseIteratorFromBaseConverter,
0125 ValueToBaseConverter, ValueFromBaseConverter,
0126 KeyFromBaseValueConverter,
0127 FunctorsFromDerivedClasses
0128
0129 >::type base_;
0130
0131
0132
0133 public:
0134
0135 typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::first_type key_type;
0136 typedef BOOST_DEDUCED_TYPENAME Iterator::value_type::second_type data_type;
0137 typedef data_type mapped_type;
0138
0139 protected:
0140
0141 typedef BOOST_DEDUCED_TYPENAME mpl::if_< ::boost::mpl::is_na<KeyFromBaseValueConverter>,
0142
0143 detail::key_from_pair_extractor< BOOST_DEDUCED_TYPENAME Iterator::value_type >,
0144
0145
0146
0147 KeyFromBaseValueConverter
0148
0149
0150 >::type key_from_base_value;
0151
0152
0153
0154 public:
0155
0156 explicit list_map_adaptor(Base & c) :
0157 base_(c) {}
0158
0159 protected:
0160
0161 typedef list_map_adaptor list_map_adaptor_;
0162
0163
0164
0165 public:
0166
0167
0168
0169
0170 template< class Predicate >
0171 void remove_if(Predicate pred)
0172 {
0173 this->base().remove_if(
0174 ::boost::bimaps::container_adaptor::detail::unary_check_adaptor
0175 <
0176 Predicate,
0177 BOOST_DEDUCED_TYPENAME Base::value_type,
0178 key_from_base_value
0179
0180 >( pred, this->template functor<key_from_base_value>() )
0181 );
0182 }
0183
0184 void unique()
0185 {
0186 this->base().unique(
0187 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0188 <
0189 std::equal_to<key_type>,
0190 BOOST_DEDUCED_TYPENAME Base::value_type,
0191 key_from_base_value
0192
0193 >(
0194 std::equal_to<key_type>(),
0195 this->template functor<key_from_base_value>()
0196 )
0197 );
0198 }
0199
0200 template< class BinaryPredicate >
0201 void unique(BinaryPredicate binary_pred)
0202 {
0203 this->base().unique(
0204 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0205 <
0206 BinaryPredicate,
0207 BOOST_DEDUCED_TYPENAME Base::value_type,
0208 key_from_base_value
0209
0210 >( binary_pred, this->template functor<key_from_base_value>() )
0211 );
0212 }
0213
0214 void merge(list_map_adaptor & x)
0215 {
0216 this->base().merge(x.base(),
0217 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0218 <
0219 std::less<key_type>,
0220 BOOST_DEDUCED_TYPENAME Base::value_type,
0221 key_from_base_value
0222
0223 >(
0224 std::less<key_type>(),
0225 this->template functor<key_from_base_value>()
0226 )
0227 );
0228 }
0229
0230 template< class Compare >
0231 void merge(list_map_adaptor & x, Compare comp)
0232 {
0233 this->base().merge(x.base(),
0234 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0235 <
0236 Compare,
0237 BOOST_DEDUCED_TYPENAME Base::value_type,
0238 key_from_base_value
0239
0240 >( comp, this->template functor<key_from_base_value>() )
0241 );
0242 }
0243
0244 void sort()
0245 {
0246 this->base().sort(
0247 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0248 <
0249 std::less<key_type>,
0250 BOOST_DEDUCED_TYPENAME Base::value_type,
0251 key_from_base_value
0252
0253 >(
0254 std::less<key_type>(),
0255 this->template functor<key_from_base_value>()
0256 )
0257 );
0258 }
0259
0260 template< class Compare >
0261 void sort(Compare comp)
0262 {
0263 this->base().sort(
0264 ::boost::bimaps::container_adaptor::detail::comparison_adaptor
0265 <
0266 Compare,
0267 BOOST_DEDUCED_TYPENAME Base::value_type,
0268 key_from_base_value
0269
0270 >( comp, this->template functor<key_from_base_value>() )
0271 );
0272 }
0273
0274 };
0275
0276
0277 }
0278 }
0279 }
0280
0281
0282 #endif
0283