Skip to content

Instantly share code, notes, and snippets.

@oliora
Last active January 2, 2016 17:09
Show Gist options
  • Select an option

  • Save oliora/8335282 to your computer and use it in GitHub Desktop.

Select an option

Save oliora/8335282 to your computer and use it in GitHub Desktop.
#include <iostream>
template<typename T>
struct Foo
{
void do_something();
Foo()
{
std::cout << "ctor" << std::endl;
}
};
template<>
void Foo<int>::do_something()
{
std::cout << "int" << std::endl;
}
template<>
void Foo<double>::do_something()
{
std::cout << "double" << std::endl;
}
int main()
{
Foo<int>().do_something();
Foo<double>().do_something();
return 0;
}
@oliora
Copy link
Copy Markdown
Author

oliora commented Jan 9, 2014

It compiles and works under gcc and MSVS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment