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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:17:12+00:00 2026-06-13T10:17:12+00:00

The original problem I tried to solve when stumbled upon this was to select

  • 0

The original problem I tried to solve when stumbled upon this was to select parse_impl version:

  • if the parser (of type U) provides a field named "skp", use that field;
  • if not, use a default value.

I came up with the following code:

// This variant compiles for parsers requiring a skipper:
template <typename I, typename U, typename A,
          typename = typename std::enable_if<
              not std::is_same<
                  typename std::remove_reference<U>::type::skipper_type,
                  qi::unused_type
              >::value
          >::type,
          typename = void > // avoid redefinition (1 more overload not shown)
bool parse_impl(I & start, I end, U && parser, A & attr)
{
    // qi::space by default:
    return qi::phrase_parse(start, end, parser, qi::space, attr);
}

// This variant compiles for parsers providing skipper via 'skp' member:
template <typename I, typename U, typename A,
          typename = typename std::enable_if<
              not std::is_same<
                  typename std::remove_reference<U>::type::skipper_type,
                  qi::unused_type
              >::value
              && (sizeof(U::skp) != 0)
          >::type,
          typename = void, typename = void > // avoid redefinition
bool parse_impl(I & start, I end, U && parser, A & attr)
{
    // parser.skp is available:
    return qi::phrase_parse(start, end, parser, parser.skp, attr);
}

The call site look like this:

pr.is_ok = parse_impl(pr.position, input.cend(), parser, pr.attr);

and this is called both for types having skp and ones that haven’t.

And it compiles (on gcc4.7), but I don’t understand why: when skp is present, expressions in both enable_ifs should evaluate to true (skipper_type is obviously not equal to unused_type then), and the call should be ambiguous. Where am I mistaken?

  • 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-13T10:17:13+00:00Added an answer on June 13, 2026 at 10:17 am

    The problem here is, as concluded in the comments, that when using just U::skp, it might be that U is deduced as a reference type (i.e., when passing an lvalue parser). When this happens, you get SFINAE going, as a reference type obviously has no nested anything.

    The fix is to remove the reference from U with std::remove_reference so that you have (sizeof(std::remove_reference<T>::type::skp) != 0). Note that typename is not needed here, since ::skp indicates that type has to be a typename.

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

Sidebar

Related Questions

I have encountered this solution for a problem I tried to solve (uncheck radio
I searched and tried for hours to solve this problem, unfortunately without success. I
This is a slightly original variation on a common problem. I have a fairly
I tried to solve one programming problem(neither my homework nor any of my interview/test,
PS. I prefer to solve this problem with CSS if possible but if there
Original Problem: I have 3 boxes each containing 200 coins, given that there is
Original Problem In building our projects, I want the mercurial id of each repository
Original problem: What is the right column format for a unix timestamp? The net
My original problem was how to map multidimensional int array to string.Following was the
ORIGINAL TEXT REMOVED OK, so I found the original problem thanks to a helpful

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.