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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:28:45+00:00 2026-06-09T15:28:45+00:00

In a class that mixes CRTP, variadic templates, metaprogrammation and operator overloading, I would

  • 0

In a class that mixes CRTP, variadic templates, metaprogrammation and operator overloading, I would like to compare two variadic unsigned int templates parameters in order to do some static assertion. I think that helper structs would be a good way to do this but I don’t know exactly how to do it. I think about something of the form :

template<unsigned int... TDIM, unsigned int... TDIM0> struct HelperCheckDimensions
{
    static const bool ok = /* SOMETHING */
};

where TDIM and TDIM0 are the two parameters I want to compare. It will allow me to type :

static_assert(HelperCheckDimensions<TDIM..., TDIM0...>::ok, "ERROR : Dimensions are different !");

I want the result to be true only if sizeof...(TDIM)==sizeof...(TDIM0) AND TDIM[0] == TDIM0[0], TDIM[1] == TDIM0[1], ..., TDIM[n] == TDIM0[n].

How to do that ?

Thank you very much.

  • 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-09T15:28:46+00:00Added an answer on June 9, 2026 at 3:28 pm

    I would say a class variadic-template of this form doesn’t make sense:

    template<unsigned int... TDIM, unsigned int... TDIM0> 
    struct HelperCheckDimensions
    {
        //..
    };
    

    It doesn’t make sense, because if I write this:

    HelperCheckDimensions<1,2,3,4,5,6> z;
    

    then what TDIM and TDIM0 should be? How the compiler should do partition of the arguments?

    Is this correct:

    TDIM = (1,2)
    TDIM0 = (3,4,5,6)
    

    Or is this correct:

    TDIM = (1)
    TDIM0 = (2,3,4,5,6)
    

    Or this:

    TDIM = (1,2,3,4)
    TDIM0 = (5,6)
    

    Hope that helps why it doesn’t make sense.


    From your comment:

    Very good point ! But my question remains open… Maybe something of the form template<unsigned int... TDIM, typename TFAKE, unsigned int... TDIM0> would work ? What is the best solution?

    Well the template definition of this form is not allowed by the Standard:

    template<unsigned int... TDIM, typename TFAKE, unsigned int... TDIM0>
    

    I don’t know the reasons why the Standard doesn’t allow it even though it makes sense to me, at least in this case (maybe it adds unworthy complexity to the language). According to the Standard, the template-parameter-pack must be the last parameter of a template definition.

    If you compile the above code in GCC, it gives this error:

    error: parameter pack ‘TDIM’ must be at the end of the template parameter list

    Hope that helps.

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

Sidebar

Related Questions

Say I have two traits that I would like to mixin to a class.
I've got a class that looks like: public class Competitor { public virtual int
I have a C# class that has some functionality that I'd like to allow
I would like to know how to write unit tests for a module that
I have a class that I instantiate to save or load xml data. For
I have a Class that has a private variable with a public setter/getter function:
I have a class that has several member classes as attributes. The constructor of
There is a ParsedTemplate class that it has over 300 property (typed Details and
I have a class that gets a movieClip and then using addChild adds it
I m creating a class that extends AlertDialog. and setting layout. But when pop

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.