
On Sat, 24 Jun 2006 12:34:43 +0100, "John Maddock" <john@johnmaddock.co.uk> wrote:
Gennaro Prota wrote:
[...]
Yep that can be simplied quite a bit, done in cvs. I haven't added the static_cast's: it obfuscates the code and serves no real purpose - no value can actually ever be returned.
Thanks, I could have done that myself, but I always prefer to ask for the original developer, first, just to be sure I'm not missing anything.
NOTE: Going a bit further null_item() is not necessary, as one could use a return *(new T) directly in failed_range_check(), though I haven't thought of all the consequences in the case operator new is overloaded.
Not so sure about that.
Yeah, of course the type of the expression *(new T) would always be T, but I'm not sure if it may cause code bloat in case the compiler is not able to see that it is never reached. After a couple of nights of sleep I find the static T solution preferable.
* why are the two operator[]() functions range-checked for the case N==0? And what's the point of those BOOST_ASSERT( "out of range" )?
No idea - Alistair?
I've removed them for now since they serve no purpose that I can see: they'll always pass won't they?
Tricky question. IMHO it is undefined behavior. When BOOST_ASSERT falls back to the standard assert it really depends on the underlying library. C90 does not require that assert works with expressions having non-int type. In C99 it shall work for any scalar expression (which anyway "out of range" is not; it has array type). We could perhaps protect against this kinds of things by using a static_cast in assert.hpp (probably documenting that) --Gennaro.