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

x
?
Solved

Function Template Specialization with two arguments

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

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

template<>
int myfunction(int val)
{
      AfxMessageBox("interger");
      //S var = 50;
      return 5;
}

when  I inovke it as
myfunction<int,int>(4); or
myfunction<int>(4);
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.
0
Comment
Question by:mjp_25
1 Comment
 
LVL 48

Accepted Solution

by:
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.
0

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