By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,820 Members | 1,187 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,820 IT Pros & Developers. It's quick & easy.

template specialization hides other specializations-msvc6

P: n/a
The following code gives the output "1.21.21.2" with msvc6,
while it gives "1.2T34" with g++.

What's up with this?

Regards, Tom
----
#include <iostream>
using namespace std;

template<class T>
void plum() { cout << "T"; }

template<>
void plum<double>() { cout << 1.2; }

template<>
void plum<int>() { cout << 34; }

int main()
{
plum<double>();
plum<bool>();
plum<int>();
return 0;
}
Jul 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"Tom Richardson" <th*****************@yahoo.com> wrote...
The following code gives the output "1.21.21.2" with msvc6,
while it gives "1.2T34" with g++.

What's up with this?
VC++ v6 cannot handle template specialisations. It always calls
the first one it encounters. A known bug.

Regards, Tom
----
#include <iostream>
using namespace std;

template<class T>
void plum() { cout << "T"; }

template<>
void plum<double>() { cout << 1.2; }

template<>
void plum<int>() { cout << 34; }

int main()
{
plum<double>();
plum<bool>();
plum<int>();
return 0;
}

Jul 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.