[Please don't cross-post C++ questions to comp.lang.c, it gets them mad]
I wouldn't normally, but the post I was replying to included C++ code
on
comp.lang.c. If it was wrong then I thought it should be pointed out on
clc.
Though of course anyone one who takes C++ advice from comp.lang.c is in
a state of sin...
[testing an unsigned against -1]
Warning 650: Constant '-1' out of range for operator '!='
If I was writing C++ code, I'd have the choice of:
numeric_limits< Type >::max()
But nonetheless I'd still use -1.
As for the warning sending chills up your spine, you can always cast
it away:
i != (unsigned)-1;
or, in C++:
i != implicit_cast<unsigned>( -1 );
is this a new type of cast?
I think it exists in Boost.
Also, it's something that was recently under discussion in comp.std.c++.
Check out the thread "Defect: Missing fundamental feature!"
http://groups.google.com/group/comp.std.c++/browse_frm/thread/8b7617618a67f610/
ah. Interesting. Thankyou very much
--
Nick Keighley
"If, indeed the subatomic energy in the stars is being freely
used to maintain their great furnaces, it seems to bring a little
nearer to fulfillment our dreams of controlling this latent
power for the well-being of the human race - or for its suicide."
Aurthur S. Eddington "The Internal Constitution of the Stars" 1926