
On Fri, Oct 1, 2010 at 2:34 PM, alfC
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.c...
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)
You are using GCC, phrase_parse's first parameter must be non-const. Visual studio can accept a const in a non-const if it is a temporary, as above. GCC however, follows the standard, meaning that you must create an iterator for at least the s.begin() and pass the iterator in, not a temporary, meaning change the above lines to this: std::string s = "(2, 3)"; // < line added to example std::string::iterator iter = s.begin(); bool r = phrase_parse(iter, s.end(), //< only line changed in the example was (first, last)