[Interest] Help, please !!!
realnc at gmail.com
Fri Apr 27 00:29:23 CEST 2012
On 27/04/12 01:09, Scott Aron Bloom wrote:
> On 27/04/12 00:45, Scott Aron Bloom wrote:
>> Nope. That was not the issue. The issue was that when you append
>> list A into list B, you can't get to list A because what's inside list
>> B is a copy of A, not A itself. You might want to read again from the
>> first post.
>> Nope.. not at all..
>> The problem is with your testcase Nikos... NOT implicit sharing..
>> Expliticly PREVENTS the modification of the listOfInts variable.
>> It takes in a const object reference, Guarenteeing the original will
>> NOT be modified.. And implying that any modification to the original
>> will not effect the copy as well..
> I said:
> You said:
> If someOtherList goes out of scope, you will be pointing to
> a deleted list.
> Since QList uses implicit sharing, the cost of removing the
> inner pointer isn't that much.
> QList< QList< int> >
> Is much safer.
> I said:
> Note that with QList< QList<int> > you can't modify the other
> lists. You'd only be modifying the copies.
> You said:
> Not true at all..
> I don't see what it is that we're discussing here. Your statement was
> simply wrong. My suggestion to be able to modify the other list:
> Your suggestion to be able to modify the other list:
> which doesn't work. You will *not* be able to modify 'someOtherList'
> through 'list'. It's basic C++. You *need* to hold a pointer, or else
> you're dealing with a copy. Whether that copy uses implicit sharing
> doesn't matter at all; implicit sharing is just an optimization.
I'm not sure if you're serious or are trolling me for fun. I *do* have
a sense of humor, but this one I don't get :-/
How is this "wrong?" You claim that if you do:
QList< QList<int> > list;
you are able to modify 'someOtherList' through 'list'. You just can't.
Not the list, and also not its contents (since they're 'int', not
'int*'). If you really are serious about what you're saying, even after
this discussion, then I have to give up.
> If the container list, allowed for non-const parameters passing (like it
> could in Qt 3.0) You COULD "copy" the original and modify it.
Isn't that the point? That you CANNOT modify it through the copy,
therefore if you do need to modify it you need a pointer rather than a
copy? But at the same time you claim the opposite.
Or this is some kind of miscommunication.
> But keeping a pointer to something on the stack, that could go out of
> scope, is VERY VERY dangerous...
No one claimed otherwise.
More information about the Interest