File indexing completed on 2025-01-18 09:29:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_BIMAP_CONTAINER_ADAPTOR_ORDERED_ASSOCIATIVE_CONTAINER_ADAPTOR_HPP
0013 #define BOOST_BIMAP_CONTAINER_ADAPTOR_ORDERED_ASSOCIATIVE_CONTAINER_ADAPTOR_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/associative_container_adaptor.hpp>
0022 #include <boost/bimap/container_adaptor/detail/comparison_adaptor.hpp>
0023 #include <boost/mpl/if.hpp>
0024 #include <boost/mpl/vector.hpp>
0025 #include <boost/mpl/push_front.hpp>
0026 #include <boost/mpl/aux_/na.hpp>
0027 #include <boost/operators.hpp>
0028 #include <boost/call_traits.hpp>
0029
0030 namespace boost {
0031 namespace bimaps {
0032 namespace container_adaptor {
0033
0034 #ifndef BOOST_BIMAP_DOXYGEN_WILL_NOT_PROCESS_THE_FOLLOWING_LINES
0035
0036 template
0037 <
0038 class Base, class Iterator, class ConstIterator,
0039 class ReverseIterator, class ConstReverseIterator, class KeyType,
0040 class IteratorToBaseConverter, class IteratorFromBaseConverter,
0041 class ReverseIteratorFromBaseConverter,
0042 class ValueToBaseConverter, class ValueFromBaseConverter,
0043 class KeyToBaseConverter,
0044 class FunctorsFromDerivedClasses
0045 >
0046 struct ordered_associative_container_adaptor_base
0047 {
0048 typedef associative_container_adaptor<
0049 Base, Iterator, ConstIterator, KeyType,
0050 IteratorToBaseConverter, IteratorFromBaseConverter,
0051 ValueToBaseConverter, ValueFromBaseConverter, KeyToBaseConverter,
0052
0053 BOOST_DEDUCED_TYPENAME mpl::push_front<
0054
0055 FunctorsFromDerivedClasses,
0056
0057 BOOST_DEDUCED_TYPENAME mpl::if_<
0058 ::boost::mpl::is_na<ReverseIteratorFromBaseConverter>,
0059
0060 detail::iterator_from_base_identity
0061 <
0062 BOOST_DEDUCED_TYPENAME Base::reverse_iterator,
0063 ReverseIterator,
0064 BOOST_DEDUCED_TYPENAME Base::const_reverse_iterator,
0065 ConstReverseIterator
0066 >,
0067
0068
0069
0070 ReverseIteratorFromBaseConverter
0071
0072
0073 >::type
0074
0075 >::type
0076
0077 > type;
0078 };
0079
0080 #endif
0081
0082
0083
0084 template
0085 <
0086 class Base,
0087
0088 class Iterator,
0089 class ConstIterator,
0090 class ReverseIterator,
0091 class ConstReverseIterator,
0092
0093 class KeyType,
0094
0095 class IteratorToBaseConverter = ::boost::mpl::na,
0096 class IteratorFromBaseConverter = ::boost::mpl::na,
0097 class ReverseIteratorFromBaseConverter = ::boost::mpl::na,
0098 class ValueToBaseConverter = ::boost::mpl::na,
0099 class ValueFromBaseConverter = ::boost::mpl::na,
0100 class KeyToBaseConverter = ::boost::mpl::na,
0101
0102 class FunctorsFromDerivedClasses = mpl::vector<>
0103 >
0104 class ordered_associative_container_adaptor :
0105
0106 public ordered_associative_container_adaptor_base
0107 <
0108 Base, Iterator, ConstIterator,
0109 ReverseIterator, ConstReverseIterator, KeyType,
0110 IteratorToBaseConverter, IteratorFromBaseConverter,
0111 ReverseIteratorFromBaseConverter,
0112 ValueToBaseConverter, ValueFromBaseConverter, KeyToBaseConverter,
0113 FunctorsFromDerivedClasses
0114
0115 >::type,
0116
0117 ::boost::totally_ordered
0118 <
0119 ordered_associative_container_adaptor
0120 <
0121 Base, Iterator, ConstIterator,
0122 ReverseIterator, ConstReverseIterator,
0123 KeyType, IteratorToBaseConverter, IteratorFromBaseConverter,
0124 ReverseIteratorFromBaseConverter,
0125 ValueToBaseConverter, ValueFromBaseConverter,
0126 KeyToBaseConverter, FunctorsFromDerivedClasses
0127 >
0128 >
0129 {
0130
0131
0132 typedef BOOST_DEDUCED_TYPENAME ordered_associative_container_adaptor_base
0133 <
0134 Base, Iterator, ConstIterator,
0135 ReverseIterator, ConstReverseIterator, KeyType,
0136 IteratorToBaseConverter, IteratorFromBaseConverter,
0137 ReverseIteratorFromBaseConverter,
0138 ValueToBaseConverter, ValueFromBaseConverter, KeyToBaseConverter,
0139 FunctorsFromDerivedClasses
0140
0141 >::type base_;
0142
0143 public:
0144
0145 typedef detail::compatible_comparison_adaptor
0146 <
0147 BOOST_DEDUCED_TYPENAME Base::key_compare,
0148 BOOST_DEDUCED_TYPENAME base_::key_type,
0149 BOOST_DEDUCED_TYPENAME base_::key_to_base
0150
0151 > key_compare;
0152
0153 typedef detail::comparison_adaptor
0154 <
0155 BOOST_DEDUCED_TYPENAME Base::value_compare,
0156 BOOST_DEDUCED_TYPENAME base_::value_type,
0157 BOOST_DEDUCED_TYPENAME base_::value_to_base
0158
0159 > value_compare;
0160
0161 typedef ReverseIterator reverse_iterator;
0162 typedef ConstReverseIterator const_reverse_iterator;
0163
0164 protected:
0165
0166 typedef BOOST_DEDUCED_TYPENAME mpl::if_<
0167 ::boost::mpl::is_na<ReverseIteratorFromBaseConverter>,
0168
0169 detail::iterator_from_base_identity
0170 <
0171 BOOST_DEDUCED_TYPENAME Base::reverse_iterator,
0172 reverse_iterator,
0173 BOOST_DEDUCED_TYPENAME Base::const_reverse_iterator,
0174 const_reverse_iterator
0175 >,
0176
0177
0178
0179 ReverseIteratorFromBaseConverter
0180
0181
0182 >::type reverse_iterator_from_base;
0183
0184
0185
0186 public:
0187
0188 explicit ordered_associative_container_adaptor(Base & c)
0189 : base_(c) {}
0190
0191 protected:
0192
0193 typedef ordered_associative_container_adaptor
0194 ordered_associative_container_adaptor_;
0195
0196
0197
0198 public:
0199
0200 reverse_iterator rbegin()
0201 {
0202 return this->template functor<
0203 reverse_iterator_from_base
0204 >() ( this->base().rbegin() );
0205
0206 }
0207
0208 reverse_iterator rend()
0209 {
0210 return this->template functor<
0211 reverse_iterator_from_base
0212 >() ( this->base().rend() );
0213 }
0214
0215 const_reverse_iterator rbegin() const
0216 {
0217 return this->template functor<
0218 reverse_iterator_from_base
0219 >() ( this->base().rbegin() );
0220 }
0221
0222 const_reverse_iterator rend() const
0223 {
0224 return this->template functor<
0225 reverse_iterator_from_base
0226 >() ( this->base().rend() );
0227 }
0228
0229 key_compare key_comp() const
0230 {
0231 typedef BOOST_DEDUCED_TYPENAME base_::key_to_base key_to_base_;
0232
0233 return key_compare(
0234 this->base().key_comp(),
0235 this->template functor<key_to_base_>()
0236 );
0237 }
0238
0239 value_compare value_comp() const
0240 {
0241 typedef BOOST_DEDUCED_TYPENAME base_::value_to_base value_to_base_;
0242
0243 return value_compare(
0244 this->base().value_comp(),
0245 this->template functor<value_to_base_>()
0246 );
0247 }
0248
0249 template< class CompatibleKey >
0250 BOOST_DEDUCED_TYPENAME base_::iterator lower_bound(const CompatibleKey & k)
0251 {
0252 return this->template functor<
0253 BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(
0254 this->base().lower_bound(
0255 this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)
0256 )
0257 );
0258 }
0259
0260 template< class CompatibleKey >
0261 BOOST_DEDUCED_TYPENAME base_::const_iterator lower_bound(const CompatibleKey & k) const
0262 {
0263 return this->template functor<
0264 BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(
0265 this->base().lower_bound(
0266 this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)
0267 )
0268 );
0269 }
0270
0271 template< class CompatibleKey >
0272 BOOST_DEDUCED_TYPENAME base_::iterator upper_bound(const CompatibleKey & k)
0273 {
0274 return this->template functor<
0275 BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(
0276 this->base().upper_bound(
0277 this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)
0278 )
0279 );
0280 }
0281
0282 template< class CompatibleKey >
0283 BOOST_DEDUCED_TYPENAME base_::const_iterator upper_bound(const CompatibleKey & k) const
0284 {
0285 return this->template functor<
0286 BOOST_DEDUCED_TYPENAME base_::iterator_from_base>()(
0287 this->base().upper_bound(
0288 this->template functor<BOOST_DEDUCED_TYPENAME base_::key_to_base>()(k)
0289 )
0290 );
0291 }
0292
0293
0294
0295 bool operator==(const ordered_associative_container_adaptor & c) const
0296 {
0297 return ( this->base() == c.base() );
0298 }
0299
0300 bool operator<(const ordered_associative_container_adaptor & c) const
0301 {
0302 return ( this->base() < c.base() );
0303 }
0304 };
0305
0306
0307 }
0308 }
0309 }
0310
0311
0312 #endif