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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T03:12:49+00:00 2026-06-09T03:12:49+00:00

I have a recursive variadic templated method that is called from a non-recursive variadic

  • 0

I have a recursive variadic templated method that is called from a non-recursive variadic templated method (probably not relevant but I’ll mention it just in case):

template < class T, class UnaryPredicate, typename... UnaryPredicates >
static bool checkPredicate( const T obj,
                            const UnaryPredicate& p,
                            UnaryPredicates... predicates )
{
    bool output = p( obj );
    if ( output && sizeof...( UnaryPredicates ) ) {
        output = checkPredicate( obj, predicates... );  //  The problem line.
    }

    return output;
}

However when called with:

.. = checkPredicate< Sy_simObject*, VisiblePredicate< Sy_simObject* >( .. );

It gives me the following error:

error: no matching function for call to
‘Sy_project::checkPredicate(Sy_simObject* const&)’

I understand that the error is telling me that UnaryPredicates is empty, and there is no overload for just T, and sure enough if I put one in it compiles fine. But I don’t understand how it could have gotten that far with the sizeof...( UnaryPredicates ) check in the conditional? Surely if there were no more it would have evaluated as false and the recursion would have ended?

I can fix it by just adding the overload, by I really want to understand why it doesn’t work now.

  • 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-09T03:12:51+00:00Added an answer on June 9, 2026 at 3:12 am

    Because if(cond) { body } is a runtime if. The fact that the compiler can know before-hand at compile time that it doesn’t need to branch at runtime can be used to optimize the generated code, but it must not influence whether it complains about certain parts of the code.

    If the code of the body is invalid if cond is false, the compiler will complain. What you are looking for is a static if, which controls whether certain parts of your code is processed by the compiler or not. There are proposals for such a thing for the next C++ version, but current C++ does not have such a construct.

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

Sidebar

Related Questions

I have a recursive method on the base form that takes in a control
I have a recursive method that returns categories, and checks for its sub categories.
I have a recursive call to a method that throws a stack overflow exception.
I have a recursive template definition (I just made up that term). I think
I have a recursive method that reversed a string (HW assignment, has to be
I have a recursive method that allocates an NSMutableArray, runs a recursive call and
I have a recursive method that builds a tree-like structure of a resource and
I have a recursive function fact , which can be called from either an
i have a recursive query like this (note: this is just an example): var
I have this recursive method which deletes empty folders: private void DeleteEmpty(DirectoryInfo directory) {

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.