there:
What is the result of the following codes?
foo.h
#include <iostream>
template<class _Tp>
struct Foo
{
void print() { std::cout << "foo\n"; }
};
foo.cxx
#include "foo.h"
template<>
void Foo<int>::print()
{
std::cout << "foo<int>\n";
}
main.cxx
#include "foo.h"
int main()
{
Foo<double>().print();
Foo<int>().print();
return 0;
}
The results are different:
when complied by MSVC,
foo foo
when compiled by g++,
foo foo<int>
I would like to get the second result regardless of compilers. What should I do additionally to achieve? If possible, would you give me an explanation about underlying standards or mechanism. Thank you!