Re: sorted_vector, constness, pointers, and structs

2012-07-19 Thread Stephan Bergmann
On 07/18/2012 08:09 PM, Lubos Lunak wrote: What you want is broken. It is definitely broken from the theoretical point of view, since modifying the items may change the sort order. While one can argue that it is broken, in practice I would not bother trying too hard to make the code safe

Re: sorted_vector, constness, pointers, and structs

2012-07-19 Thread Lubos Lunak
On Wednesday 18 of July 2012, Noel Grandin wrote: On Wed, Jul 18, 2012 at 8:09 PM, Lubos Lunak l.lu...@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

Re: sorted_vector, constness, pointers, and structs

2012-07-19 Thread Lubos Lunak
On Thursday 19 of July 2012, Stephan Bergmann wrote: On 07/18/2012 08:09 PM, Lubos Lunak wrote: What you want is broken. It is definitely broken from the theoretical point of view, since modifying the items may change the sort order. While one can argue that it is broken, in practice I

Re: sorted_vector, constness, pointers, and structs

2012-07-18 Thread Noel Grandin
On Wed, Jul 18, 2012 at 7:23 PM, Lubos Lunak l.lu...@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

Re: sorted_vector, constness, pointers, and structs

2012-07-18 Thread Lubos Lunak
On Wednesday 18 of July 2012, Noel Grandin wrote: On Wed, Jul 18, 2012 at 7:23 PM, Lubos Lunak l.lu...@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

Re: sorted_vector, constness, pointers, and structs

2012-07-18 Thread Noel Grandin
On Wed, Jul 18, 2012 at 8:09 PM, Lubos Lunak l.lu...@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. Aargh. Instead of casting

sorted_vector, constness, pointers, and structs

2012-07-18 Thread Noel Grandin
Hi So David and Stephan recommended that I make the accessor methods to o3tl::sorted_vector const in order to prevent clients from invalidating the sorted-ness of it. This works out fine when I'm storing pointers to something in the sorted_vector like this: struct SomeStruct { int xxx;

Re: sorted_vector, constness, pointers, and structs

2012-07-18 Thread Lubos Lunak
On Wednesday 18 of July 2012, Noel Grandin wrote: Hi So David and Stephan recommended that I make the accessor methods to o3tl::sorted_vector const in order to prevent clients from invalidating the sorted-ness of it. This works out fine when I'm storing pointers to something in the