Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3844756
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:08:21+00:00 2026-05-19T16:08:21+00:00

I recently wrote some spirit parsing code in windows, which I recently have tried

  • 0

I recently wrote some spirit parsing code in windows, which I recently have tried to get build on an ubuntu box and have ran into a compilation error that I am struggling with.

After some hacking and slashing, I have managed to come up with this example code snippet which exhibits the same behavior:

struct FooParser
: spirit::qi::grammar<
    std::string::const_iterator, 
    double(), 
    spirit::qi::ascii::space_type>
{
    FooParser() : FooParser::base_type(a_rule)
    {
        using namespace boost::spirit::qi;
        a_rule = double_;
    }

    spirit::qi::rule<
        string::const_iterator,
        double(),
        spirit::qi::ascii::space_type> a_rule;
};

which is then passed to a phrase_parse like so:

double result;
std::string txt;
FooParser foobar;
//...
if(phrase_parse(txt.begin(), txt.end(), foobar, space, result))
{
//do something
}

And when compiled, generates the following error:

boost/spirit/home/qi/reference.hpp:41: error: no matching function for call to 
‘boost::spirit::qi::rule<__gnu_cxx::__normal_iterator<const char*, std::basic_string<char,
 std::char_traits<char>, std::allocator<char> > >, double(), 
boost::proto::exprns_::expr<boost::proto::tag::terminal, 
boost::proto::argsns_::term<boost::spirit::tag::char_code<boost::spirit::tag::space, 
boost::spirit::char_encoding::ascii> >, 0l>, boost::fusion::unused_type, 
boost::fusion::unused_type>::parse(__gnu_cxx::__normal_iterator<char*, 
std::basic_string<char, std::char_traits<char>, std::allocator<char> > >&, const 
__gnu_cxx::__normal_iterator<char*, std::basic_string<char, std::char_traits<char>, 
std::allocator<char> > >&, const boost::fusion::unused_type&, const 
boost::spirit::qi::char_class<boost::spirit::tag::char_code<boost::spirit::tag::space, 
boost::spirit::char_encoding::ascii> >&, double&) const’

The thing that I find frustrating is that visual studio seems more than happy to compile and run the code. I am hoping that the wise internets can show me where I have erred.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:08:22+00:00Added an answer on May 19, 2026 at 4:08 pm

    I think the problem here is the begin() and end() of std::string, try this:

    std::string::const_iterator begin = txt.begin();
    std::string::const_iterator end = txt.end();
    

    then pass that in:

    phrase_parse(begin, end, foobar, space, result)
    

    The problem I believe is that everywhere else you are using the type const_iterator, but begin(), end() on a non const string returns a normal iterator.

    The key part of the error is this bit:

    parse(__gnu_cxx::__normal_iterator, std::allocator > >&, const
    __gnu_cxx::__normal_iterator,
    std::allocator > >&

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Recently a co-worker of mine wrote in some code to catch a null pointer
I recently wrote some code that uses the same unsigned short to store two
I recently wrote some javascript code that filled a drop down list based on
I wrote some code recently (ISO/ANSI C), and was surprised at the poor performance
I recently wrote some Javascript code to generate random fake stock data as I
I'm refactoring some code that a friend wrote and recently stumbled across this function:
I recently wrote an Eclipse plugin, and I'm trying to get some coworkers to
I recently wrote some data access methods (plain old Java) that use immutable objects
I recently wrote a script which queries PyPI and downloads a package; however, the
Recently I had faced compiling errors in a c++ code I wrote so I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.