[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SV: Problems



(catching up on my Email)

> > Very, very weird is the fact that the template functions min
> > and max are NOT
> > defined in the header algortihms.h as they should be. The best I get in
> > cstdlib is this:
>
> Have a look in <xutility>, they are defined there. <algorithms> includes
> <xutility>.
>
No, they are not, not in the MS CV++ version of xutility. Rather, the min
and max functions has been replaced by the functions _cpp_min and _cpp_max.
Defines are made so that _MIN and _MAX can be used instead.

The reason for this is that windows defines its own min and max in a header
called windef.h

This is where it happens there:

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif

#ifndef min
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#endif


Now, these are macros. In other words, they do not do the job as one would
expect min() and max() to do. Think min(val++, val2).