//: C05:MinTest2.cpp // From "Thinking in C++, Volume 2", by Bruce Eckel & Chuck Allison. // (c) 1995-2004 MindView, Inc. All Rights Reserved. // See source code use permissions stated in the file 'License.txt', // distributed with the code package available at www.MindView.net. #include #include using std::strcmp; using std::cout; using std::endl; template const T& min(const T& a, const T& b) { return (a < b) ? a : b; } // An explicit specialization of the min template template<> const char* const& min(const char* const& a, const char* const& b) { return (strcmp(a, b) < 0) ? a : b; } int main() { const char *s2 = "say \"Ni-!\"", *s1 = "knights who"; cout << min(s1, s2) << endl; cout << min<>(s1, s2) << endl; } ///:~