#include #include using std::cout; using std::endl; using std::string; // returns 0 if equal, 1 if value1 is bigger, -1 otherwise template int compare(const T &value1, const T &value2) { if (value1 < value2) return -1; if (value2 < value1) return 1; return 0; } int main(int argc, char **argv) { string h("hello"), w("world"); cout << compare(10, 20) << endl; // ok cout << compare(h, w) << endl; // ok cout << compare(50.5, 50.6) << endl; // ok // what type did the compiler infer here? cout << compare("Hello", "World") << endl; // hmm... return EXIT_SUCCESS; }