Jeroen T. Vermeulen wrote: > Now, there's one thing here that makes me curious: this is the first time > I've ever heard of these macros ever being _needed_ for anything. First > time in fact I heard of even a theoretical possibility of them making any > difference at all (apart from breaking things, of course). Practically > all code I can think of should just work as normal if one replaced the > macros with the standard functions, and a lot of proper code would > suddenly start working. So does afxtempl.h explicitly check for the > presence of min() and max() macros, and refuse to work if they're not > there? If so, why? If not, what goes wrong if they're not there?
The problem with std::min() and std::max() is that they require two exactly equal arguments. The following code: short s = 5; int i = 3; int result = std::max(s,i); fails with these errors: D:\Documents and Settings\bsamwel\Local Settings\Temp\tcppsrc.cpp(5) : error C2780: 'const _Ty &std::max(const _Ty &,const _Ty &,_Pr)' : expects 3 arguments - 2 provided C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xutility(1250) : see declaration of 'std::max' D:\Documents and Settings\bsamwel\Local Settings\Temp\tcppsrc.cpp(5) : error C2782: 'const _Ty &std::max(const _Ty &,const _Ty &)' : template parameter '_Ty' is ambiguous C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xutility(1242) : see declaration of 'std::max' could be 'int' or 'short' I could do without the first error, but the second error is pretty clear: it can't deduce the template argument. This is the general cause of problems when using std::min and std::max instead of macros. Cheers, Bart _______________________________________________ Libpqxx-general mailing list Libpqxx-general@gborg.postgresql.org http://gborg.postgresql.org/mailman/listinfo/libpqxx-general