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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:08:42+00:00 2026-06-04T06:08:42+00:00

I have the following rule in boost::spirit : typedef boost::tuple<int, int> Entry; qi::rule<Iterator, Entry(),

  • 0

I have the following rule in boost::spirit:

typedef boost::tuple<int, int> Entry;
qi::rule<Iterator, Entry(), Skipper> entry;
entry = qi::int_ >> qi::int_;

But the second int is not written into the tuple. Is there a way to make it work without having to use boost::fusion::tuple?

It works if I use std::pair, so why can’t I use boost::tuple?

Here is a full compiling example:

#include <iostream>
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/include/tuple.hpp>
#include <boost/tuple/tuple.hpp>
namespace qi = boost::spirit::qi;

// works:
// #include <boost/fusion/include/std_pair.hpp>
// typedef std::pair<int, int> Entry;

// doesn't work:
typedef boost::tuple<int, int> Entry;

template <typename Iterator, typename Skipper>
struct MyGrammar : qi::grammar<Iterator, Entry(), Skipper> {
  MyGrammar() : MyGrammar::base_type(entry) {
    entry = qi::int_ >> qi::int_;
  }
  qi::rule<Iterator, Entry(), Skipper> entry;
};

int main() {
  const std::string in = "1 3";
  typedef std::string::const_iterator It;
  It it = in.begin();

  Entry entry;
  MyGrammar<It, qi::space_type> gr;
  if (qi::phrase_parse(it, in.end(), gr, qi::space, entry)
      && it == in.end()) {
    std::cout << boost::get<0>(entry) << "," << boost::get<1>(entry) << std::endl;
  }
  return 0;
}
  • 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-06-04T06:08:44+00:00Added an answer on June 4, 2026 at 6:08 am

    In order for Spirit to recognize boost::tuple<> as a valid Fusion sequence, you need to include an additional header:

    #include <boost/fusion/include/boost_tuple.hpp>
    

    This is somewhat loosely hinted at in the docs here.

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

Sidebar

Related Questions

Say I have a Boost Spirit grammar like this, where a parent rule passes
I am new to boost spirit and I have the following problem: #include <string>
So, I have the following spirit karma rule body: base_rule = eps(_r1 != 0)
I am trying to have the following regx rule, but couldn't find solution. I
I have the following css rule in my document font-family: Trebuchet MS, Tahoma; but
I have the following Apache Rewrite rule <IfModule rewrite_module> RewriteEngine on RewriteMap tolowercase int:tolower
I have the following rule in my current .htaccess file to redirect /videos/login/ requests
I have created following rule in the .htaccess file located at the root of
I have the following rule defined in the .htaccess file of my webapplication's root
In my .htaccess file I have defined following rule, RewriteRule t/([^.]+)/$ /videos/tag.php?tag=$1 [QSA] The

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.