|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r82759 - trunk/libs/spirit/doc/support
From: hartmut.kaiser_at_[hidden]
Date: 2013-02-06 20:26:27
Author: hkaiser
Date: 2013-02-06 08:20:02 EST (Wed, 06 Feb 2013)
New Revision: 82759
URL: http://svn.boost.org/trac/boost/changeset/82759
Log:
Spirit: fix #7977: functor_input example for multi_pass iterator has various issues
Text files modified:
trunk/libs/spirit/doc/support/multi_pass.qbk | 33 +++++++++++++++++++++++----------
1 files changed, 23 insertions(+), 10 deletions(-)
Modified: trunk/libs/spirit/doc/support/multi_pass.qbk
==============================================================================
--- trunk/libs/spirit/doc/support/multi_pass.qbk (original)
+++ trunk/libs/spirit/doc/support/multi_pass.qbk 2013-02-06 08:20:02 EST (Wed, 06 Feb 2013)
@@ -353,16 +353,22 @@
to know whether the input has reached the end. Last but not least the function
object must be default constructible. Here is an example:
+ #include <iostream>
+ #include <boost/spirit/home/qi.hpp>
+ #include <boost/spirit/home/support.hpp>
+ #include <boost/spirit/home/support/multi_pass.hpp>
+ #include <boost/spirit/home/support/iterators/detail/functor_input_policy.hpp>
+
// define the function object
class iterate_a2m
{
public:
typedef char result_type;
- iterate_a2m() : c('A') {}
+ iterate_a2m() : c_('A') {}
iterate_a2m(char c) : c_(c) {}
- result_type operator()() const
+ result_type operator()()
{
if (c_ == 'M')
return eof;
@@ -375,24 +381,31 @@
char c_;
};
- iterate_a2m::result_type iterate_a2m::eof = iterate_a2m::result_type('\0');
+ iterate_a2m::result_type iterate_a2m::eof = iterate_a2m::result_type('M');
+
+ using namespace boost::spirit;
// create two iterators using the define function object, one of which is
// an end iterator
typedef multi_pass<iterate_a2m
- , iterator_policies::functor_input
, iterator_policies::first_owner
, iterator_policies::no_check
+ , iterator_policies::functor_input
, iterator_policies::split_std_deque>
functor_multi_pass_type;
- functor_multi_pass_type first = functor_multi_pass_t(iterate_a2m());
- functor_multi_pass_type last;
+ int main()
+ {
+ functor_multi_pass_type first = functor_multi_pass_type(iterate_a2m());
+ functor_multi_pass_type last;
- // use the iterators: this will print "ABCDEFGHIJKL"
- while (first != last) {
- std::cout << *first;
- ++first;
+ // use the iterators: this will print "ABCDEFGHIJKL"
+ while (first != last) {
+ std::cout << *first;
+ ++first;
+ }
+ std::cout << std::endl;
+ return 0;
}
[heading How to write policies for use with multi_pass]
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk