Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, May 2008
Re: QMap::operator[]


Message 1 in thread

The reason for the change is that all of the containers in QT4 are reference
counted and have private data pointers to the real data such that:
sizeof(Container) == sizeof(void *).

this means that things like: QMap<QString> a = b; is just a copy of a
pointer and increment of a refernce count. Pretty much just as cheap as a
reference (which is just a copy of a pointer).

At least that's my understanding of it.

Evan Teran


Vladimir Romanovskiy wrote:

> Hi,
> 
> In Qt 3.3.8 the const operator QMap::operator[] returned a constant
> reference:
> 
> const T & QMap::operator[] ( const Key & k ) const
> 
> In 4.3.4 the same operator now returns a constant object:
> 
> const T QMap::operator[] ( const Key & key ) const
> 
> Why was changed that important operator?
> Temporary object that created with this operator results in hidden errors!
> 
> Thanks,
> Vladimir
> 
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/

--
 [ signature omitted ]