Skip to content

Instantly share code, notes, and snippets.

@longlongjump
Last active March 14, 2016 17:11
Show Gist options
  • Select an option

  • Save longlongjump/cd6d800a1b7095efd4f6 to your computer and use it in GitHub Desktop.

Select an option

Save longlongjump/cd6d800a1b7095efd4f6 to your computer and use it in GitHub Desktop.
#include <iostream>
template<typename T>
void foo(T val) {
std::cout << "void foo<T>(T val)" << std::endl;
}
void foo(int val) {
std::cout << "void foo(int val)" << std::endl;
}
template<typename T>
void test(T val) {
foo(val);
}
int main() {
test(42); //prints "void foo(int val)"
test("42"); //prints "void foo<T>(T val)"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment