Skip to content

Instantly share code, notes, and snippets.

@cblp
Last active August 29, 2015 14:23
Show Gist options
  • Select an option

  • Save cblp/41f958cded6207716364 to your computer and use it in GitHub Desktop.

Select an option

Save cblp/41f958cded6207716364 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
template <typename A>
A antiId(A x) { return x; }
template <>
int antiId<int>(int) { return 42; }
int main() {
cout << 1 << '\t' << antiId(1) << endl;
// 1 42
cout << "test" << '\t' << antiId("test") << endl;
// "test" "test"
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment