Skip to content

Instantly share code, notes, and snippets.

@hideki1234
Created September 17, 2018 01:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hideki1234/7d870f7ed115be925159682ad4e9aa35 to your computer and use it in GitHub Desktop.
Save hideki1234/7d870f7ed115be925159682ad4e9aa35 to your computer and use it in GitHub Desktop.
#include <iostream>
template<typename T>
void func(T)
{
std::cout << "generic\n";
}
template<>
void func<int>(int)
{
std::cout << "specialized for int\n";
}
void func(int)
{
std::cout << "regular function\n";
}
int main()
{
func(1.5); // generic
func<int>(2); // specialized for int
func(3); // regular function
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment