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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:53:36+00:00 2026-05-24T01:53:36+00:00

I am investigating a problem with C++ class templates. One class template is specialized

  • 0

I am investigating a problem with C++ class templates. One class template is specialized but the compiler does not always choose to use the specialization. I found that the constructor arguments seem to influence this:

temlate <class T> 
class MyClass { /*some constructors*/ };

template<>
class MyClass <int>
{ void foo(); /*some constructors*/}

MyClass<int> test1; 
test1.foo(); //works

MyClass<int> test1("hallo"); 
test1.foo(); //doesn't work (foo does not exist, compiler uses unspecialized version.)

I haven’t managed to create a sample that shows the problem because the constructor arguments are pretty complex (and the problem does not occur with simple arguments).

But my question is simply this: Is it possible, that constructor arguments influence the choice of the compiler? How?

I am working with Visual C++ 2008.

Thanks a lot!

—- EDIT:

It seems like we have identified the problem: If the template specialization was not part of all the translation units in the static library that we build, the problem occurs. But it disappears, if there are no other translation units.

I found http://codeidol.com/cpp/cpp-templates/Instantiation/Implementation-Schemes/ and it seems to me that with the Greedy Implementation the phenomena we observed can be explained.

Does anybody know which implementation schemes are actually used by MSVC and GCC?

  • 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-24T01:53:37+00:00Added an answer on May 24, 2026 at 1:53 am

    But my question is simply this: Is it possible, that constructor
    arguments influence the choice of the compiler? How?

    No, because you are telling it which type you want to use :

    MyClass<int> test1; 
    test1.foo(); //works
    

    is always creating objects of the specialized type.

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

Sidebar

Related Questions

I'm investigating a performance problem with Jetty 6.1.26. Jetty appears to use Transfer-Encoding: chunked
I am currently investigating a double request problem on my site. Not all the
Update : This works in firefox, but does not work on chrome 6, still
While I was investigating a problem I had with lexical closures in Javascript code,
While investigating a reported problem with my site loading slowly, I came across an
While investigating an issue with application I'm working on, I've came across one behavior
I'm currently investigating a problem with a 3rd party component (DevExpress) in my application.
I am currently in the process of investigating a very peculiar problem on our
Just today learned that one of my websites, TwitPeek.net, is not rendering properly in
We are investigating a problem with a site we created that only exists on

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.