[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Function Template Specialization with two arguments

Posted on 2004-11-27
Medium Priority
Last Modified: 2010-04-24
I have one function template. It takes two arguments. I have used Specialization.

template <class S, class T>
S myfunction(T val)
      S var = 50;
      return var;

int myfunction(int val)
      //S var = 50;
      return 5;

when  I inovke it as
myfunction<int,int>(4); or
It goes in first definition and prints "T".
Why it is not following the function template specialization?
If I run it in Visual studio 6 then it gives correct result. Means follows the function template specialization.
Please try to suggest the appropriate solution.
Question by:mjp_25
1 Comment
LVL 48

Accepted Solution

AlexFM earned 500 total points
ID: 12685779
I tested in VC++ 6.0 and gets "integer" in both cases. If you get another result with some other compiler, this means, compiler implements template specialization by wrong way.

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The following diagram presents a diamond class hierarchy: As depicted, diamond inheritance denotes when two classes (e.g., CDerived1 and CDerived2), separately extending a common base class (e.g., CBase), are sub classed simultaneously by a fourt…
In Easy String Encryption Using CryptoAPI in C++ (http://www.experts-exchange.com/viewArticle.jsp?aid=1193) I described how to encrypt text and recommended that the encrypted text be stored as a series of hexadecimal digits -- because cyphertext may…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question