template specialization hides other specializations-msvc6

T

Tom Richardson

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;
}
 
V

Victor Bazarov

Tom Richardson said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top