RE: Some trouble with qldefines.hpp
Posted by
Nicolas Di Césaré on
Nov 02, 2001; 5:35am
URL: http://quantlib.414.s1.nabble.com/Some-trouble-with-qldefines-hpp-tp1787p1792.html
En réponse à Luigi Ballabio <
[hidden email]>:
> At 12:49 PM 11/2/01 +0100, Jens Thiel wrote:
> We might define it in qldefines.hpp---or rather in config.msvc.hpp which
>
> config.hpp includes if the compiler is Visual C++. I'm not sure how
> solid
> that would be, though: it would work fine if we always write
>
> #include <ql/qldefines.hpp>
> #include <algorithm>
>
> but what if one forgets and writes
>
> #include <algorithm>
> #include <ql/qldefines.hpp>
After reading boost mailing list, I think we have to mix the both ideas. In
qldefines.hpp we can check if NOMINMAX is defined and if not
print a message asking user to define it in the preprocessor definitions.
#if defined HAVE_LIMITS
#if !defined(NOMINMAX)
#pragma message("Add NOMINMAX to preprocessor definitions ...")
# undef min
# undef max
namespace std
{
template<class T> inline const T &max(const T &x, const T &y)
{ return x < y ? y : x; }
template<class T> inline const T &min(const T &x, const T &y)
{ return y < x ? y : x; }
}
#include <limits>
...
--
Nicolas Di Césaré
http://acm.emath.fr/~dicesare