sorted_vector, constness, pointers, and structs
l.lunak at suse.cz
Thu Jul 19 01:04:56 PDT 2012
On Wednesday 18 of July 2012, Noel Grandin wrote:
> On Wed, Jul 18, 2012 at 8:09 PM, Lubos Lunak <l.lunak at suse.cz> wrote:
> > You didn't read further than that part above, did you?
> > What you want is broken. It is definitely broken from the theoretical
> > point of view, since modifying the items may change the sort order.
> Aaaaaargh. Instead of casting aspersions on my replies, how about you
> actually read the o3tl::sorted_vector.hxx code
I have. Speaking of which, it would be very nice if new API was actually
documented, such as the not immediately obvious return value of insert(). And
I'll leave wondering about the performance of random inserts in a vector to
> and look at some of the use-cases in the LO codebase.
I won't. It doesn't really change anything about what I've said, and moreover
if you wanted me to do that, you could have pointed me to a specific place
with such a problem, instead of me having to look for it, if it's there
already at all.
> What is broken is attempting to provide a level of protection that is
> not useful in practice, mostly get bypassed, and does not play nice
> with the C++ type-system.
Look, either you do provide accessors that allow direct modifying of the
elements, or you don't. If you do, I don't see your motivation to start this
thread, since even though you started it by saying that David and Stephan
recommended it, you try to dismiss that the entire time, so what's the point?
What is broken is your entire problem, you apparently just don't see it.
> Now, however, if you look at my original email, I make some
> suggestions that will actually improve things.
> For example, we can split the problem into 2 sub-use-cases
> (a) sorted_vector_of_ptr_to_val
> (b) sorted_vector_of_val
> Then for each of these cases, we can apply some degree (but not a lot)
> of const-protection
I've told you that the ptr vs non-ptr distinction is most probably not needed
at all. Maybe you should start with reminding to read things with you?
l.lunak at suse.cz
More information about the LibreOffice