|
Boost Users : |
Subject: Re: [Boost-users] [intrusive] first impression and constant-time removal
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2009-02-06 12:47:47
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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net