Boost logo

Boost Users :

Subject: [Boost-users] [spirit][qi] Iteration / string iterator
From: alfC (alfredo.correa_at_[hidden])
Date: 2010-10-01 16:34:53


can anybody explain to me why this example from the Spirit.Qi manual
works

http://www.boost.org/doc/libs/1_44_0/libs/spirit/example/qi/complex_number.cpp

and when I try to use the string iterators directly I get a horrific
compiler error? Something to do with string iterators being pointers
or something?

        std::string s = "(2, 3)"; // < line added to example
        bool r = phrase_parse(s.begin(), s.end(), //< only line
changed in the example was (first, last)
            // Begin grammar
            (
                    '(' >> double_[ref(rN) = _1]
>> -(',' >> double_[ref(iN) = _1]) >> ')'
                | double_[ref(rN) = _1]
            ),
            // End grammar

            space);

Thank you
Alfredo
error message below:

complex_number.cpp: In function 'bool client::parse_complex(Iterator,
Iterator, std::complex<double>&) [with Iterator =
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >]':
complex_number.cpp:81: instantiated from here
complex_number.cpp:51: error: no matching function for call to
'phrase_parse(__gnu_cxx::__normal_iterator<char*,
std::basic_string<char, std::char_traits<char>, std::allocator<char> >
>, __gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, const
boost::proto::exprns_::expr<boost::proto::tag::bitwise_or,
boost::proto::argsns_::list2<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l>, const
boost::proto::exprns_::expr<boost::proto::tag::subscript,
boost::proto::argsns_::list2<const
boost::spirit::terminal<boost::spirit::tag::double_>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const
boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval,
boost::fusion::vector<boost::phoenix::reference<double>,
boost::spirit::argument<0>, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >&>, 0l> >, 2l>&>, 2l>&, const
boost::proto::exprns_::expr<boost::proto::tag::negate,
boost::proto::argsns_::list1<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l>, const
boost::proto::exprns_::expr<boost::proto::tag::subscript,
boost::proto::argsns_::list2<const
boost::spirit::terminal<boost::spirit::tag::double_>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const
boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval,
boost::fusion::vector<boost::phoenix::reference<double>,
boost::spirit::argument<0>, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >&>, 0l> >, 2l>&>, 2l>&>, 1l>&>, 2l>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l> >, 2l>&, const
boost::proto::exprns_::expr<boost::proto::tag::subscript,
boost::proto::argsns_::list2<const
boost::spirit::terminal<boost::spirit::tag::double_>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const
boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval,
boost::fusion::vector<boost::phoenix::reference<double>,
boost::spirit::argument<0>, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >&>, 0l> >, 2l>&>, 2l>, const
boost::spirit::ascii::space_type&)'
/g/g91/correaa/usr/include/boost/spirit/home/qi/parse.hpp:62: note:
candidates are: bool boost::spirit::qi::phrase_parse(Iterator&,
Iterator, const Expr&, const Skipper&,
boost::spirit::qi::skip_flag::enum_t) [with Iterator =
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, Expr =
boost::proto::exprns_::expr<boost::proto::tag::bitwise_or,
boost::proto::argsns_::list2<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l>, const
boost::proto::exprns_::expr<boost::proto::tag::subscript,
boost::proto::argsns_::list2<const
boost::spirit::terminal<boost::spirit::tag::double_>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const
boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval,
boost::fusion::vector<boost::phoenix::reference<double>,
boost::spirit::argument<0>, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >&>, 0l> >, 2l>&>, 2l>&, const
boost::proto::exprns_::expr<boost::proto::tag::negate,
boost::proto::argsns_::list1<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l>, const
boost::proto::exprns_::expr<boost::proto::tag::subscript,
boost::proto::argsns_::list2<const
boost::spirit::terminal<boost::spirit::tag::double_>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const
boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval,
boost::fusion::vector<boost::phoenix::reference<double>,
boost::spirit::argument<0>, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >&>, 0l> >, 2l>&>, 2l>&>, 1l>&>, 2l>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l> >, 2l>&, const
boost::proto::exprns_::expr<boost::proto::tag::subscript,
boost::proto::argsns_::list2<const
boost::spirit::terminal<boost::spirit::tag::double_>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const
boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval,
boost::fusion::vector<boost::phoenix::reference<double>,
boost::spirit::argument<0>, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >&>, 0l> >, 2l>&>, 2l>, Skipper =
boost::spirit::ascii::space_type]
/g/g91/correaa/usr/include/boost/spirit/home/qi/detail/parse_auto.hpp:
164: note: bool
boost::spirit::qi::phrase_parse(Iterator&, Iterator, Expr&, const
Skipper&, boost::spirit::qi::skip_flag::enum_t) [with Iterator =
__gnu_cxx::__normal_iterator<char*, std::basic_string<char,
std::char_traits<char>, std::allocator<char> > >, Expr = const
boost::proto::exprns_::expr<boost::proto::tag::bitwise_or,
boost::proto::argsns_::list2<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l>, const
boost::proto::exprns_::expr<boost::proto::tag::subscript,
boost::proto::argsns_::list2<const
boost::spirit::terminal<boost::spirit::tag::double_>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const
boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval,
boost::fusion::vector<boost::phoenix::reference<double>,
boost::spirit::argument<0>, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >&>, 0l> >, 2l>&>, 2l>&, const
boost::proto::exprns_::expr<boost::proto::tag::negate,
boost::proto::argsns_::list1<const
boost::proto::exprns_::expr<boost::proto::tag::shift_right,
boost::proto::argsns_::list2<boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l>, const
boost::proto::exprns_::expr<boost::proto::tag::subscript,
boost::proto::argsns_::list2<const
boost::spirit::terminal<boost::spirit::tag::double_>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const
boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval,
boost::fusion::vector<boost::phoenix::reference<double>,
boost::spirit::argument<0>, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >&>, 0l> >, 2l>&>, 2l>&>, 1l>&>, 2l>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const char&>, 0l> >, 2l>&, const
boost::proto::exprns_::expr<boost::proto::tag::subscript,
boost::proto::argsns_::list2<const
boost::spirit::terminal<boost::spirit::tag::double_>&,
boost::proto::exprns_::expr<boost::proto::tag::terminal,
boost::proto::argsns_::term<const
boost::phoenix::actor<boost::phoenix::composite<boost::phoenix::assign_eval,
boost::fusion::vector<boost::phoenix::reference<double>,
boost::spirit::argument<0>, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_> > >&>, 0l> >, 2l>&>, 2l>, Skipper =
boost::spirit::ascii::space_type]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net