Zeljko Vrba wrote:
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.:
Thanks for the warning. However, I doubt Interprocess is being used in generic code because unlike standard containers, I don't think there are no generic equivalents for these type of containers. If this only breaks very little code I think the change could be worth of it. Otherwise, for non-constant-time lists this operation would be very inefficient since users would need to call O(N) count() to know how many instances have been erased. Regards, Ion