Created
September 17, 2018 01:35
-
-
Save hideki1234/7d870f7ed115be925159682ad4e9aa35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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