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 7191183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:40:25+00:00 2026-05-28T19:40:25+00:00

I am making a parser with spirit::qi and aim for making it compatible with

  • 0

I am making a parser with spirit::qi and aim for making it compatible with different char sizes.

template < typename Iterator >
struct grammar : qi::grammar < Iterator >
{
    grammar () : grammar::base_type ( file, alter_string_size_to < Iterator::value_type > ( _szFile ) )
    {

    }

    qi::rule < Iterator > file;
};

Given that

alter_string_size_to < Iterator::value_type > ( _szFile )

successfully returns a pointer to a string containing _szFile in the required char size.

When I compile with

Iterator = std::wstring::const_iterator

I get following error message

cannot convert parameter 2 from 'unsigned short *' to 'const std::string &'

So .. grammar::base_type is only expecting an const std::string & as the second parameter.
My question is, how can I tell qi::grammar to expect a string with its Iterators value_type size ?

Thanks in advance !

  • 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-28T19:40:26+00:00Added an answer on May 28, 2026 at 7:40 pm

    It’s defined as follows in the source:

        grammar(
            start_type const& start
          , std::string const& name_ = "unnamed-grammar")
        : proto::extends<terminal, base_type>(terminal::make(reference_(start)))
        , name_(name_)
        {}
    
        std::string name_;
    

    So you can’t. As it’s stated in the doc:

    name is an optional string that gives the grammar its name, useful for debugging and error handling.

    So, you’ll have to make your own lookup based on it.

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

Sidebar

Related Questions

I'm making an xml parser to parse xml reports from different tools, and each
I'm making a script parser in python and I'm a little stuck. I am
I am currently making a simple calculator parser in Java, to deal only with
i'm making my own bbcode parser, and i've a problem when i try to
I am making get request in PHP but the parser is having issues. I
I was messing around with making a command line parser and was wondering what
I have a language I am making a parser for which contains function calls.
Since I've never encountered this kind of problem I thought about making language parser
I'm making a static analyzer for C. I have done the lexer and parser
I am trying to write a parser in Python for a special text file

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.