Boost logo

Boost :

From: Mark Rodgers (mark.rodgers_at_[hidden])
Date: 2000-07-05 03:36:20


I have some code that uses std::min and std::max. Of course it doesn't
work with MSVC. The work around I have used is

#if defined(BOOST_MSVC) && _MSC_VER <= 1200 && !defined(NOMINMAX)
# undef min
# undef max
# define NOMINMAX
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; }
}
#endif

I'm working on theory that if NOMINMAX is defined, someone else is
probably doing a similar workaround and I shouldn't attempt my fix.

Two questions:

1. Is my workaround correct, and has anyone got any better ideas?
2. Is something along these lines something we should put in
   config.hpp or elsewhere?

One possibility is that we could have a boost/algorithm.hpp that
includes <algorithm> and then applies this fix. Similarly we could
have boost/cstddef.hpp where the
 
    namespace std { using ::ptrdiff_t; using ::size_t; }

fix could reside instead of in config.hpp.

Thoughts?

Mark


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk