[Interest] Help, please !!!

Scott Aron Bloom Scott.Bloom at onshorecs.com
Fri Apr 27 00:48:45 CEST 2012


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<int> someOtherList;
   QList< QList<int> > list;
   list.append(someOtherList);

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.
----------------
It has NOTHING TO DO WITH THE int vs int*, It has EVERYTHING to do with
you are sending in a const copy of the someOtherList...

----------------

> 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.
--------------------------

I claim, that with implicit sharing YOU CAN MODIFY the original list...
however, not via the constant.. Try using the operator[] instead.
-------------------

> But keeping a pointer to something on the stack, that could go out of 
> scope, is VERY VERY dangerous...

No one claimed otherwise.
----------------

You did when you suggested you use 

push( &otherList )


You are coming to the correct conclusing, but not for the correct
reason.. Using append/pushback etc, the list is copied using a const
reference to the data..

Implicit sharing or not, will not allow modifications on either the copy
or the original to propagate to the other...  Just as iff you did a
constant pointer to the original.

Scott









More information about the Interest mailing list