|
Boost : |
From: John Maddock (john_at_[hidden])
Date: 2004-01-03 07:44:05
> No. I'm including 2 programs, one for which including <algorithm> does
> *not* remove the ambiguity, and one for which the inclusion of win32.hpp
> silently changes the meaning of the program. This fooling with the
> min/max macros simply has to go.
>
> //
> // inclusion of win32.hpp silently changes the meaning of a program
> //
> #include <iostream>
> using std::cout;
> using std::endl;
>
> #include <windows.h>
>
> void foo()
> {
> unsigned long i = 1;
> signed long j = -1;
> cout << max(i,j) << endl;
> cout << typeid(max(i,j)).name() << endl;
> cout << endl;
> }
>
> #include <algorithm>
> #include <boost/utility.hpp>
>
> void bar()
> {
> unsigned long i = 1;
> signed long j = -1;
> cout << max(i,j) << endl;
> cout << typeid(max(i,j)).name() << endl;
> cout << endl;
> }
>
> int main()
> {
> foo();
> bar();
> return 0;
> }
>
> Output:
>
> 4294967295
> unsigned long
>
> 1
> long
I have to admit I'm amazed by the behaviour of the macro versions here -
they may be std conforming, but in what way are these correct? All the more
reason to regard signed/unsigned comparisons as errors IMO. Anyway, you are
correct, this change in behaviour is unacceptable, lets get the release out
the way, and then address this properly.
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk