[Qt-interest] Const correctness with QSharedPointer

Colin Kern colin.kern at gmail.com
Wed Dec 9 17:11:00 CET 2009


On Tue, Dec 8, 2009 at 1:37 PM, Thiago Macieira <thiago at kde.org> wrote:
> Em Terça-feira 08 Dezembro 2009, às 19:11:08, Hostile Fork escreveu:
>> > On Mon, Dec 7, 2009 at 4:31 PM, Stephen Jackson <spjackson42 at gmail.com>
>> > wrote:
>> >
>> > I'm going to hijack my own thread here, since I have another question
>> > about QSharedPointers.  Is there a way to maintain polymorphism when
>> > using QSharedPointers?
>>
>> Not too long ago I did a survey of smart pointer variants with respect to
>>  this issue (for std::auto_ptr, std::unique_ptr, boost::unique_ptr, and
>>  std::tr1::shared_ptr) and you might find it useful:
>>
>>       http://hostilefork.com/2009/07/10/smart-pointer-casting-study/
>>
>> I didn't include QSharedPointer because I did not know about it at that
>>  time (someone linked me to it after the post).
>>
>> But I saw in Thiago's followup that it worked for him.  So I'm not going to
>>  try it just now until there's resolution on which compiler + Qt version
>>  doesn't do it.  But if that is resolved I'm happy to add a  QSharedPointer
>>  example to the article with whatever caveats are appropriate.
>
> The testcase entered our testing system 15 minutes ago (the previous build
> took 15 hours and 22 minutes to finish). We'll know if any of the following
> platforms experience any problems in 12 hours:
>
> - vs2003
> - vs2005
> - vs2008
> - mingw 4.4
> - macx cocoa64
> - macx cocoa32
> - macx carbon
> - linux-g++
> - qws/linux-g++-x86
> - wincewm60 vs2008
> - solaris-cc-64
> - solaris-g++-64
> - symbian 3.2 arm
> - symbian 3.2 winscw
>
> The remaining supported platforms will have to wait a little longer (aix-xlc,
> hpuxi-acc, qws-arm, qws-mips, mingw 3.4 and the other Symbian versions).
>
> However, since there are a number of other down-cast tests, I doubt that this
> will be an issue anywhere.
>
> The only issue I currently know of with QSharedPointer is a miscompilation
> with vs2003 in a very particular case. See the QEXPECT_FAIL in
> tst_qsharedpointer.cpp in the Qt sources to see what it is.
>
> --
> Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
>  Senior Product Manager - Nokia, Qt Development Frameworks
>      PGP/GPG: 0x6EF45358; fingerprint:
>      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>

My system where I experienced the compiler error was using linux-g++
and Qt 4.5.2.  Maybe this has been fixed in 4.6?

Colin




More information about the Qt-interest-old mailing list