ext/boost/range/concepts.hpp in passenger-3.0.21 vs ext/boost/range/concepts.hpp in passenger-3.9.1.beta

- old
+ new

@@ -96,12 +96,13 @@ // Rationale for the inclusion of redefined iterator concept // classes: // // The Range algorithms often do not require that the iterators are - // Assignable, but the correct standard conformant iterators - // do require the iterators to be a model of the Assignable concept. + // Assignable or default constructable, but the correct standard + // conformant iterators do require the iterators to be a model of the + // Assignable concept. // Iterators that contains a functor that is not assignable therefore // are not correct models of the standard iterator concepts, // despite being adequate for most algorithms. An example of this // use case is the combination of the boost::adaptors::filtered // class with a boost::lambda::bind generated functor. @@ -139,10 +140,30 @@ BOOST_RANGE_CONCEPT_ASSERT(( Convertible< BOOST_DEDUCED_TYPENAME SinglePassIteratorConcept::traversal_category, single_pass_traversal_tag >)); + + BOOST_CONCEPT_USAGE(SinglePassIteratorConcept) + { + Iterator i2(++i); + boost::ignore_unused_variable_warning(i2); + + // deliberately we are loose with the postfix version for the single pass + // iterator due to the commonly poor adherence to the specification means that + // many algorithms would be unusable, whereas actually without the check they + // work + (void)(i++); + + BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r1(*i); + boost::ignore_unused_variable_warning(r1); + + BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r2(*(++i)); + boost::ignore_unused_variable_warning(r2); + } + private: + Iterator i; #endif }; template<class Iterator> struct ForwardIteratorConcept @@ -158,9 +179,23 @@ BOOST_RANGE_CONCEPT_ASSERT(( Convertible< BOOST_DEDUCED_TYPENAME ForwardIteratorConcept::traversal_category, forward_traversal_tag >)); + + BOOST_CONCEPT_USAGE(ForwardIteratorConcept) + { + // See the above note in the SinglePassIteratorConcept about the handling of the + // postfix increment. Since with forward and better iterators there is no need + // for a proxy, we can sensibly require that the dereference result + // is convertible to reference. + Iterator i2(i++); + boost::ignore_unused_variable_warning(i2); + BOOST_DEDUCED_TYPENAME boost::detail::iterator_traits<Iterator>::reference r(*(i++)); + boost::ignore_unused_variable_warning(r); + } + private: + Iterator i; #endif }; template<class Iterator> struct BidirectionalIteratorConcept