On Thu, Feb 05, 2009 at 07:11:03PM +0100, Ion GaztaƱaga wrote:
That can be a good idea, since many lists have no constant-time size, so the user should be informed of how many elements have been erased. It's not std compliant but it does not break any code, since the function returned nothing.
I would be careful here because C++ allows void returns. An example: template<typename T> void f(T &t) { return t.remove(..); } If you change remove to return something else than void, the code above will fail to compile. This example is contrived, but things could break in more elaborate generic algorithm implementations. Heck, the simplest example of the usefulness of the above is early exit from a function, e.g.: if(something) return t.remove(..); which avoids compound statement.