comparison DEPENDENCIES/generic/include/boost/range/concepts.hpp @ 101:c530137014c0

Update Boost headers (1.58.0)
author Chris Cannam
date Mon, 07 Sep 2015 11:12:49 +0100
parents 2665513ce2d3
children
comparison
equal deleted inserted replaced
100:793467b5e61c 101:c530137014c0
21 #include <boost/range/begin.hpp> 21 #include <boost/range/begin.hpp>
22 #include <boost/range/end.hpp> 22 #include <boost/range/end.hpp>
23 #include <boost/range/iterator.hpp> 23 #include <boost/range/iterator.hpp>
24 #include <boost/range/value_type.hpp> 24 #include <boost/range/value_type.hpp>
25 #include <boost/range/detail/misc_concept.hpp> 25 #include <boost/range/detail/misc_concept.hpp>
26 #include <boost/type_traits/remove_reference.hpp>
26 27
27 /*! 28 /*!
28 * \file 29 * \file
29 * \brief Concept checks for the Boost Range library. 30 * \brief Concept checks for the Boost Range library.
30 * 31 *
61 namespace range_detail { 62 namespace range_detail {
62 63
63 #ifndef BOOST_RANGE_ENABLE_CONCEPT_ASSERT 64 #ifndef BOOST_RANGE_ENABLE_CONCEPT_ASSERT
64 65
65 // List broken compiler versions here: 66 // List broken compiler versions here:
67 #ifndef __clang__
66 #ifdef __GNUC__ 68 #ifdef __GNUC__
67 // GNUC 4.2 has strange issues correctly detecting compliance with the Concepts 69 // GNUC 4.2 has strange issues correctly detecting compliance with the Concepts
68 // hence the least disruptive approach is to turn-off the concept checking for 70 // hence the least disruptive approach is to turn-off the concept checking for
69 // this version of the compiler. 71 // this version of the compiler.
70 #if __GNUC__ == 4 && __GNUC_MINOR__ == 2 72 #if __GNUC__ == 4 && __GNUC_MINOR__ == 2
71 #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0 73 #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
72 #endif 74 #endif
73 #endif 75 #endif
76
77 #ifdef __GCCXML__
78 // GCC XML, unsurprisingly, has the same issues
79 #if __GCCXML_GNUC__ == 4 && __GCCXML_GNUC_MINOR__ == 2
80 #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
81 #endif
82 #endif
83 #endif
74 84
75 #ifdef __BORLANDC__ 85 #ifdef __BORLANDC__
76 #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0 86 #define BOOST_RANGE_ENABLE_CONCEPT_ASSERT 0
77 #endif 87 #endif
78 88
251 //! Check if a type T models the SinglePassRange range concept. 261 //! Check if a type T models the SinglePassRange range concept.
252 template<class T> 262 template<class T>
253 struct SinglePassRangeConcept 263 struct SinglePassRangeConcept
254 { 264 {
255 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT 265 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
256 typedef BOOST_DEDUCED_TYPENAME range_iterator<T const>::type const_iterator; 266 // A few compilers don't like the rvalue reference T types so just
257 typedef BOOST_DEDUCED_TYPENAME range_iterator<T>::type iterator; 267 // remove it.
258 268 typedef BOOST_DEDUCED_TYPENAME remove_reference<T>::type Rng;
259 BOOST_RANGE_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept<iterator>)); 269
260 BOOST_RANGE_CONCEPT_ASSERT((range_detail::SinglePassIteratorConcept<const_iterator>)); 270 typedef BOOST_DEDUCED_TYPENAME range_iterator<
261 271 Rng const
262 BOOST_CONCEPT_USAGE(SinglePassRangeConcept) 272 >::type const_iterator;
263 { 273
274 typedef BOOST_DEDUCED_TYPENAME range_iterator<Rng>::type iterator;
275
276 BOOST_RANGE_CONCEPT_ASSERT((
277 range_detail::SinglePassIteratorConcept<iterator>));
278
279 BOOST_RANGE_CONCEPT_ASSERT((
280 range_detail::SinglePassIteratorConcept<const_iterator>));
281
282 BOOST_CONCEPT_USAGE(SinglePassRangeConcept)
283 {
264 // This has been modified from assigning to this->i 284 // This has been modified from assigning to this->i
265 // (where i was a member variable) to improve 285 // (where i was a member variable) to improve
266 // compatibility with Boost.Lambda 286 // compatibility with Boost.Lambda
267 iterator i1 = boost::begin(*m_range); 287 iterator i1 = boost::begin(*m_range);
268 iterator i2 = boost::end(*m_range); 288 iterator i2 = boost::end(*m_range);
269 289
270 ignore_unused_variable_warning(i1); 290 boost::ignore_unused_variable_warning(i1);
271 ignore_unused_variable_warning(i2); 291 boost::ignore_unused_variable_warning(i2);
272 292
273 const_constraints(*m_range); 293 const_constraints(*m_range);
274 } 294 }
275 295
276 private: 296 private:
277 void const_constraints(const T& const_range) 297 void const_constraints(const Rng& const_range)
278 { 298 {
279 const_iterator ci1 = boost::begin(const_range); 299 const_iterator ci1 = boost::begin(const_range);
280 const_iterator ci2 = boost::end(const_range); 300 const_iterator ci2 = boost::end(const_range);
281 301
282 ignore_unused_variable_warning(ci1); 302 boost::ignore_unused_variable_warning(ci1);
283 ignore_unused_variable_warning(ci2); 303 boost::ignore_unused_variable_warning(ci2);
284 } 304 }
285 305
286 // Rationale: 306 // Rationale:
287 // The type of m_range is T* rather than T because it allows 307 // The type of m_range is T* rather than T because it allows
288 // T to be an abstract class. The other obvious alternative of 308 // T to be an abstract class. The other obvious alternative of
289 // T& produces a warning on some compilers. 309 // T& produces a warning on some compilers.
290 T* m_range; 310 Rng* m_range;
291 #endif 311 #endif
292 }; 312 };
293 313
294 //! Check if a type T models the ForwardRange range concept. 314 //! Check if a type T models the ForwardRange range concept.
295 template<class T> 315 template<class T>
299 BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::iterator>)); 319 BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::iterator>));
300 BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::const_iterator>)); 320 BOOST_RANGE_CONCEPT_ASSERT((range_detail::ForwardIteratorConcept<BOOST_DEDUCED_TYPENAME ForwardRangeConcept::const_iterator>));
301 #endif 321 #endif
302 }; 322 };
303 323
304 template<class Range> 324 template<class T>
305 struct WriteableRangeConcept 325 struct WriteableRangeConcept
306 { 326 {
307 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT 327 #if BOOST_RANGE_ENABLE_CONCEPT_ASSERT
308 typedef BOOST_DEDUCED_TYPENAME range_iterator<Range>::type iterator; 328 typedef BOOST_DEDUCED_TYPENAME range_iterator<T>::type iterator;
309 329
310 BOOST_CONCEPT_USAGE(WriteableRangeConcept) 330 BOOST_CONCEPT_USAGE(WriteableRangeConcept)
311 { 331 {
312 *i = v; 332 *i = v;
313 } 333 }
314 private: 334 private:
315 iterator i; 335 iterator i;
316 BOOST_DEDUCED_TYPENAME range_value<Range>::type v; 336 BOOST_DEDUCED_TYPENAME range_value<T>::type v;
317 #endif 337 #endif
318 }; 338 };
319 339
320 //! Check if a type T models the WriteableForwardRange range concept. 340 //! Check if a type T models the WriteableForwardRange range concept.
321 template<class T> 341 template<class T>