
Dave Handley skrev:
Comments inlined:
Markus Werle writes:
<snip>
I've got one final point to make here. I went through and reviewed the code changes in boost.range that Tom is referring to. I wouldn't be happy putting this type of code change through in my own libraries. Changing the functionality of a default constructed object just to get rid of a single test against bool in a couple of functions (ostensibly for performance) seems to me misguided.
That is of course a valid view. But take to the extreame, it means we would have to give up the "you don't pay for what you don't use" mantra.
Furthermore, having different functionality in debug and release, for most major users of a library, is just dangerous. The size and empty functions for example assert in debug, but just silent fail in release.
"Silently fail" is a bit strong here. I mean, if there are any unit-test set up, I would expect them to trigger an assert in debug-mode. I don't consider that "silent".
The issingular function is even worse, it tells you whether a range is singular in debug, but always returns false in release.
IIRC, is_singular is not documented. So using it is on your own risk. It could disappear in the next release or whatever. -Thorsten