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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:37:24+00:00 2026-05-24T17:37:24+00:00

Can somebody explain why are those two specializations indistinguishable to the compiler (gcc 4.5.1

  • 0

Can somebody explain why are those two specializations indistinguishable to the compiler (gcc 4.5.1 @ ideone)

http://ideone.com/9tNux

template <typename... T> struct S;

template<typename A, typename B, typename... C>
struct S<A, B, C...> {
   int f() {return 1;}
};

template<typename... A, typename... C>
struct S< S<A...>, C...> {
   int f() {return 2;}
};

and when I try to instantiate S<S<a, b>, a, b> o2; compiler complains:

prog.cpp:20:21: error: ambiguous class template instantiation for 'struct S<S<a, b>, a, b>'
prog.cpp:6:22: error: candidates are: struct S<A, B, C ...>
prog.cpp:11:33: error:                 struct S<S<A ...>, C ...>
prog.cpp:20:21: error: aggregate 'S<S<a, b>, a, b> o2' has incomplete type and cannot be defined

And when the last specialization is changed to:

template<typename... A, typename B, typename... C>
struct S< S<A...>, B, C...> {
   int f() {return 2;}
}

everything works fine.

  • 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-24T17:37:25+00:00Added an answer on May 24, 2026 at 5:37 pm

    My understanding of the issue:

    typedef S<S<a, b>, c, d> S2;
    

    Here S<a,b> matches the second specialization better. However, c, d is a better match for the remaining arguments of the first specialization (single arg + list vs list). Hence it is 1:1.

    If you comment in B in the second specialization, then the second specialization matches better because it is more specialized for the first argument (S<...>) and the rest are equally good.

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

Sidebar

Related Questions

can somebody please explain difference between those two declarations in the properties of the
Can somebody explain to me why the following works: template<class T> class MyTemplateClass {
Can somebody explain the main differences between (advantages / disadvantages) the two implementations? For
Can somebody explain me one thing. I have two methods in my controller :
Can somebody explain me the flow of control in this tutorial : http://www.vogella.de/articles/AndroidSQLite/article.html#tutorialusecp I
I'm a little bit confused about these two terms, can somebody explain what is
I'm a little bit confused, can somebody please explain the main difference between those
Can somebody explain to me what the below code is doing. before and after
Can somebody explain to me what this does in javascript? (function (x,y){}(x,y)); or this
Can somebody explain why the following code is not valid? Is it because 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.