File indexing completed on 2025-01-18 09:51:17
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef BOOST_RANGE_CONCEPTS_HPP
0017 #define BOOST_RANGE_CONCEPTS_HPP
0018
0019 #include <boost/concept_check.hpp>
0020 #include <boost/iterator/iterator_concepts.hpp>
0021 #include <boost/range/begin.hpp>
0022 #include <boost/range/end.hpp>
0023 #include <boost/range/iterator.hpp>
0024 #include <boost/range/value_type.hpp>
0025 #include <boost/range/detail/misc_concept.hpp>
0026 #include <boost/type_traits/remove_reference.hpp>
0027
0028 #include <iterator>
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 namespace boost {
0063
0064 namespace range_detail {
0065
0066 #ifndef BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0067
0068
0069 #ifndef __clang__
0070 #ifdef __GNUC__
0071
0072
0073
0074 #if __GNUC__ == 4 && __GNUC_MINOR__ == 2
0075 #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
0076 #endif
0077 #endif
0078
0079 #ifdef __GCCXML__
0080
0081 #if __GCCXML_GNUC__ == 4 && __GCCXML_GNUC_MINOR__ == 2
0082 #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
0083 #endif
0084 #endif
0085 #endif
0086
0087 #ifdef BOOST_BORLANDC
0088 #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
0089 #endif
0090
0091 #ifdef __PATHCC__
0092 #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
0093 #endif
0094
0095
0096
0097 #ifndef BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0098 #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 1
0099 #endif
0100
0101 #endif
0102
0103 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0104 #define BOOST_RANGE_CONCEPT_ASSERT( x ) BOOST_CONCEPT_ASSERT( x )
0105 #else
0106 #define BOOST_RANGE_CONCEPT_ASSERT( x )
0107 #endif
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124 template<class Iterator>
0125 struct IncrementableIteratorConcept : CopyConstructible<Iterator>
0126 {
0127 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0128 typedef BOOST_DEDUCED_TYPENAME iterator_traversal<Iterator>::type traversal_category;
0129
0130 BOOST_RANGE_CONCEPT_ASSERT((
0131 Convertible<
0132 traversal_category,
0133 incrementable_traversal_tag
0134 >));
0135
0136 BOOST_CONCEPT_USAGE(IncrementableIteratorConcept)
0137 {
0138 ++i;
0139 (void)i++;
0140 }
0141 private:
0142 Iterator i;
0143 #endif
0144 };
0145
0146 template<class Iterator>
0147 struct SinglePassIteratorConcept
0148 : IncrementableIteratorConcept<Iterator>
0149 , EqualityComparable<Iterator>
0150 {
0151 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0152 BOOST_RANGE_CONCEPT_ASSERT((
0153 Convertible<
0154 BOOST_DEDUCED_TYPENAME SinglePassIteratorConcept::traversal_category,
0155 single_pass_traversal_tag
0156 >));
0157
0158 BOOST_CONCEPT_USAGE(SinglePassIteratorConcept)
0159 {
0160 Iterator i2(++i);
0161 boost::ignore_unused_variable_warning(i2);
0162
0163
0164
0165
0166
0167 (void)(i++);
0168
0169 BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference r1(*i);
0170 boost::ignore_unused_variable_warning(r1);
0171
0172 BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference r2(*(++i));
0173 boost::ignore_unused_variable_warning(r2);
0174 }
0175 private:
0176 Iterator i;
0177 #endif
0178 };
0179
0180 template<class Iterator>
0181 struct ForwardIteratorConcept
0182 : SinglePassIteratorConcept<Iterator>
0183 , DefaultConstructible<Iterator>
0184 {
0185 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0186 typedef BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::difference_type difference_type;
0187
0188 BOOST_MPL_ASSERT((is_integral<difference_type>));
0189 BOOST_MPL_ASSERT_RELATION(std::numeric_limits<difference_type>::is_signed, ==, true);
0190
0191 BOOST_RANGE_CONCEPT_ASSERT((
0192 Convertible<
0193 BOOST_DEDUCED_TYPENAME ForwardIteratorConcept::traversal_category,
0194 forward_traversal_tag
0195 >));
0196
0197 BOOST_CONCEPT_USAGE(ForwardIteratorConcept)
0198 {
0199
0200
0201
0202
0203 Iterator i2(i++);
0204 boost::ignore_unused_variable_warning(i2);
0205 BOOST_DEDUCED_TYPENAME std::iterator_traits<Iterator>::reference r(*(i++));
0206 boost::ignore_unused_variable_warning(r);
0207 }
0208 private:
0209 Iterator i;
0210 #endif
0211 };
0212
0213 template<class Iterator>
0214 struct BidirectionalIteratorConcept
0215 : ForwardIteratorConcept<Iterator>
0216 {
0217 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0218 BOOST_RANGE_CONCEPT_ASSERT((
0219 Convertible<
0220 BOOST_DEDUCED_TYPENAME BidirectionalIteratorConcept::traversal_category,
0221 bidirectional_traversal_tag
0222 >));
0223
0224 BOOST_CONCEPT_USAGE(BidirectionalIteratorConcept)
0225 {
0226 --i;
0227 (void)i--;
0228 }
0229 private:
0230 Iterator i;
0231 #endif
0232 };
0233
0234 template<class Iterator>
0235 struct RandomAccessIteratorConcept
0236 : BidirectionalIteratorConcept<Iterator>
0237 {
0238 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0239 BOOST_RANGE_CONCEPT_ASSERT((
0240 Convertible<
0241 BOOST_DEDUCED_TYPENAME RandomAccessIteratorConcept::traversal_category,
0242 random_access_traversal_tag
0243 >));
0244
0245 BOOST_CONCEPT_USAGE(RandomAccessIteratorConcept)
0246 {
0247 i += n;
0248 i = i + n;
0249 i = n + i;
0250 i -= n;
0251 i = i - n;
0252 n = i - j;
0253 }
0254 private:
0255 BOOST_DEDUCED_TYPENAME BidirectionalIteratorConcept<Iterator>::difference_type n;
0256 Iterator i;
0257 Iterator j;
0258 #endif
0259 };
0260
0261 }
0262
0263
0264 template<class T>
0265 struct SinglePassRangeConcept
0266 {
0267 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0268
0269
0270 typedef BOOST_DEDUCED_TYPENAME remove_reference<T>::type Rng;
0271
0272 typedef BOOST_DEDUCED_TYPENAME range_iterator<
0273 Rng const
0274 >::type const_iterator;
0275
0276 typedef BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type iterator;
0277
0278 BOOST_RANGE_CONCEPT_ASSERT((
0279 range_detail::SinglePassIteratorConcept<iterator>));
0280
0281 BOOST_RANGE_CONCEPT_ASSERT((
0282 range_detail::SinglePassIteratorConcept<const_iterator>));
0283
0284 BOOST_CONCEPT_USAGE(SinglePassRangeConcept)
0285 {
0286
0287
0288
0289 iterator i1 = boost::begin(*m_range);
0290 iterator i2 = boost::end(*m_range);
0291
0292 boost::ignore_unused_variable_warning(i1);
0293 boost::ignore_unused_variable_warning(i2);
0294
0295 const_constraints(*m_range);
0296 }
0297
0298 private:
0299 void const_constraints(const Rng& const_range)
0300 {
0301 const_iterator ci1 = boost::begin(const_range);
0302 const_iterator ci2 = boost::end(const_range);
0303
0304 boost::ignore_unused_variable_warning(ci1);
0305 boost::ignore_unused_variable_warning(ci2);
0306 }
0307
0308
0309
0310
0311
0312 Rng* m_range;
0313 #endif
0314 };
0315
0316
0317 template<class T>
0318 struct ForwardRangeConcept : SinglePassRangeConcept<T>
0319 {
0320 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0321 BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::iterator>));
0322 BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::const_iterator>));
0323 #endif
0324 };
0325
0326 template<class T>
0327 struct WriteableRangeConcept
0328 {
0329 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0330 typedef BOOST_DEDUCED_TYPENAME range_iterator<T>::type iterator;
0331
0332 BOOST_CONCEPT_USAGE(WriteableRangeConcept)
0333 {
0334 *i = v;
0335 }
0336 private:
0337 iterator i;
0338 BOOST_DEDUCED_TYPENAME range_value<T>::type v;
0339 #endif
0340 };
0341
0342
0343 template<class T>
0344 struct WriteableForwardRangeConcept
0345 : ForwardRangeConcept<T>
0346 , WriteableRangeConcept<T>
0347 {
0348 };
0349
0350
0351 template<class T>
0352 struct BidirectionalRangeConcept : ForwardRangeConcept<T>
0353 {
0354 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0355 BOOST_RANGE_CONCEPT_ASSERT((range_detail::BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::iterator>));
0356 BOOST_RANGE_CONCEPT_ASSERT((range_detail::BidirectionalIteratorConcept<BOOST_DEDUCED_TYPENAME BidirectionalRangeConcept::const_iterator>));
0357 #endif
0358 };
0359
0360
0361 template<class T>
0362 struct WriteableBidirectionalRangeConcept
0363 : BidirectionalRangeConcept<T>
0364 , WriteableRangeConcept<T>
0365 {
0366 };
0367
0368
0369 template<class T>
0370 struct RandomAccessRangeConcept : BidirectionalRangeConcept<T>
0371 {
0372 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
0373 BOOST_RANGE_CONCEPT_ASSERT((range_detail::RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::iterator>));
0374 BOOST_RANGE_CONCEPT_ASSERT((range_detail::RandomAccessIteratorConcept<BOOST_DEDUCED_TYPENAME RandomAccessRangeConcept::const_iterator>));
0375 #endif
0376 };
0377
0378
0379 template<class T>
0380 struct WriteableRandomAccessRangeConcept
0381 : RandomAccessRangeConcept<T>
0382 , WriteableRangeConcept<T>
0383 {
0384 };
0385
0386 }
0387
0388 #endif