From a24bdfbbb19015717e7cbb6ccef138a02dddef6e Mon Sep 17 00:00:00 2001 From: Egor Derevenetc Date: Tue, 7 Feb 2017 14:01:05 +0100 Subject: [PATCH] Weaken iterator requirements in qi::parse and qi::phrase_parse Iterator used for parsing does not need to fulfil all requirements of ForwardIterator. In particular, it is fine if *it has value_type and not reference type. --- include/boost/spirit/home/qi/parse.hpp | 45 +++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/include/boost/spirit/home/qi/parse.hpp b/include/boost/spirit/home/qi/parse.hpp index 261df759cc..5f7d6d4c51 100644 --- a/include/boost/spirit/home/qi/parse.hpp +++ b/include/boost/spirit/home/qi/parse.hpp @@ -16,6 +16,7 @@ #include #include #include +#include namespace boost { namespace spirit { namespace qi { @@ -27,11 +28,12 @@ namespace boost { namespace spirit { namespace qi , Iterator last , Expr const& expr) { - // Make sure the iterator is at least a forward_iterator. If you got a - // compilation error here, then you are using an input_iterator while - // calling this function, you need to supply at least a - // forward_iterator instead. - BOOST_CONCEPT_ASSERT((ForwardIterator)); + // Make sure the iterator is at least a readable single pass iterator. + // If you got a compilation error here, then you are using a weaker iterator + // while calling this function, you need to supply a readable single pass + // iterator instead. + BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept)); + BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIteratorConcept)); return detail::parse_impl::call(first, last, expr); } @@ -71,11 +73,12 @@ namespace boost { namespace spirit { namespace qi , Expr const& expr , Attr& attr) { - // Make sure the iterator is at least a forward_iterator. If you got a - // compilation error here, then you are using an input_iterator while - // calling this function, you need to supply at least a - // forward_iterator instead. - BOOST_CONCEPT_ASSERT((ForwardIterator)); + // Make sure the iterator is at least a readable single pass iterator. + // If you got a compilation error here, then you are using a weaker iterator + // while calling this function, you need to supply a readable single pass + // iterator instead. + BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept)); + BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIteratorConcept)); // Report invalid expression error as early as possible. // If you got an error_invalid_expression error message here, @@ -108,11 +111,12 @@ namespace boost { namespace spirit { namespace qi , Skipper const& skipper , BOOST_SCOPED_ENUM(skip_flag) post_skip = skip_flag::postskip) { - // Make sure the iterator is at least a forward_iterator. If you got a - // compilation error here, then you are using an input_iterator while - // calling this function, you need to supply at least a - // forward_iterator instead. - BOOST_CONCEPT_ASSERT((ForwardIterator)); + // Make sure the iterator is at least a readable single pass iterator. + // If you got a compilation error here, then you are using a weaker iterator + // while calling this function, you need to supply a readable single pass + // iterator instead. + BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept)); + BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIteratorConcept)); return detail::phrase_parse_impl::call( first, last, expr, skipper, post_skip); @@ -142,11 +146,12 @@ namespace boost { namespace spirit { namespace qi , BOOST_SCOPED_ENUM(skip_flag) post_skip , Attr& attr) { - // Make sure the iterator is at least a forward_iterator. If you got a - // compilation error here, then you are using an input_iterator while - // calling this function, you need to supply at least a - // forward_iterator instead. - BOOST_CONCEPT_ASSERT((ForwardIterator)); + // Make sure the iterator is at least a readable single pass iterator. + // If you got a compilation error here, then you are using a weaker iterator + // while calling this function, you need to supply a readable single pass + // iterator instead. + BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIteratorConcept)); + BOOST_CONCEPT_ASSERT((boost_concepts::SinglePassIteratorConcept)); // Report invalid expression error as early as possible. // If you got an error_invalid_expression error message here,