Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


On Wed, Jul 18, 2012 at 7:23 PM, Lubos Lunak <l.lunak@suse.cz> wrote:

 But it is correct that you get an error in the second case and you ideally
should be getting one in the first case as well. You cannot modify the
elements of the vector because that might modify what defines their position
in their sorted order, isn't that so? That is exactly the reason for those

Ummm. No.
The sorted_vector class is not intended for storing primitive values.
Virtually all of the use-cases create a custom comparator operation.

Almost all of time, we are storing complex structs/classes in these
vectors, and they have numerous fields that can and do need to be
easily modifiable.
Returning const-only references defeats that.

So we end up having to cast away the const-ness most of the time,
which makes the supposed protection worthless.

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.