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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T00:50:02+00:00 2026-05-12T00:50:02+00:00

thank you for looking i got this example from my book but i cant

  • 0

thank you for looking
i got this example from my book but i cant understand why the line

  S<void,int>  sv;  // uses Template at (2)

but

S<void,char> e2;   
//uses (1) when im thinking it would use (2) especialization as well

could anyone explain the behavior?
btw all the comments in code below are from book author

thank you very much!

template<typename T> 
class Types { 
  public: 
    typedef int I; 
}; 

template<typename T, typename U = typename Types<T>::I> 
class S;                        // (1) 

template<> 
class S<void> {                 // (2) 
  public: 
    void f(); 
}; 

template<> class S<char, char> {}; // (3) 

template<> class S<char, 0>;    // ERROR: 0 cannot substitute U 

int main() 
{ 
    S<int>*      pi;   // OK: uses (1), no definition needed 
    S<int>       e1;   // ERROR: uses (1), but no definition available 
    S<void>*     pv;   // OK: uses (2) 
    S<void,int>  sv;   // OK: uses (2), definition available 
    S<void,char> e2;   // OK: uses (1), definition available 
    S<char,char> e3;   // ERROR: uses (3), but no definition available 
} 
  • 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-12T00:50:02+00:00Added an answer on May 12, 2026 at 12:50 am

    Why should it use (2)?

    (2) is a specialization of S<void, int>. What you have is S<void, char>. The types are different, so the specialization isn’t used. Specializations only apply if they match exactly. It’s not good enough that “a char can be implicitly promoted to an int”. If no specialization exists for S<void, char>, then it will use the general, nonspecialized version.

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

Sidebar

Related Questions

I have not used PackedArray before, but just started looking at using them from
I got a XML File, looking familiar to this : <root> <carnumber>12</carnumber> <carcolor>2</carcolor> <cartype>5</cartype>
Thank you for the answers. :) I'm mainly looking to host my website with
Thanks for looking, all helpful answers are voted up. This is my markup. I'm
Thanks for looking on this problem. I have a page that is totally valid
Thanks for looking at this question. I wanted to know how can I use
and thanks for looking at this question. I am porting a Linux (2.6.37) driver
I asked this question (below) a week ago and got the answer I was
This question is a spin-off/evolution of this question . (That question got marked as
I did a fair bit of searching for an answer to this question, but

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.