#include <iostream> using namespace std; template<typename T> T max(T lhs, T rhs) { return lhs < rhs ? rhs : lhs; } template<> int max<int>(int lhs, int rhs) { return lhs < rhs ? rhs : lhs; } int main() { cout << max<int>(4, 5) << endl; } ~/Documents/C++/boost $ g++ -o testSTL testSTL.cpp -Wall testSTL.cpp: In function 'int main()': testSTL.cpp:18:24: error: call of overloaded 'max(int, int)' is ambiguous testSTL.cpp:11:5: note: candidates are: T max(T, T) [with T = int] /usr/include/c++/4.5/bits/stl_algobase.h:209:5: note: const _Tp& std::max(const _Tp&, const _Tp&) [with _Tp = int]
How to fix this error?
q0987 source share