[Qt-interest] Const correctness with QSharedPointer
Hostile Fork
hostilefork at gmail.com
Tue Dec 8 19:11:08 CET 2009
> 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.
---Brian
More information about the Qt-interest-old
mailing list