Skip to content

Instantly share code, notes, and snippets.

@akihiro
Created January 25, 2013 06:45
Show Gist options
  • Save akihiro/4632307 to your computer and use it in GitHub Desktop.
Save akihiro/4632307 to your computer and use it in GitHub Desktop.
#include <iostream>
// implement
template<class T>
void implement(T t){
t++;
std::cout << t << std::endl;
}
//interface
template<class T>
void interface(T t){
implement<T>(t);
}
// specilize
template<class>
void interface<double>(double& t){
implement<double&>(t);
}
int main(){
int a = 1;
double b = 1.0;
std::cout << a << " " << b << std::endl;
interface(a);
interface(b);
std::cout << a << " " << b << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment