Going back to the original question again, as I'm not sure I agree with
this claim:

On 31/01/20 13:07, Vitaly Fanaskov wrote:
> Smart pointers are for sure much better to use than raw pointers for 
> many reasons. They manage lifetime automatically, show ownership 
> semantic, and make code safer. It’s planned to officially recommend them 
> to use in Qt6 API instead of raw pointers whenever this is possible. For 
> sure, it should only be a choice for newly designed API.

I ran a quick grep over QtBase's source code, and indeed it looks like
QSharedPointer and QScopedPointer are not used in the public API. But is
this bad?

Just imagine if we had been spreading Q{Shared,Scoped}Pointer all over
Qt's API in Qt4 times: we probably would not even be having this
conversation now, as switching from the Qt pointer classes to the std::
ones might have been way too problematic.

So, if, from this perspective, it's good that Qt has not embraced (Qt)
smart pointers before, I'm tempted to draw the conclusion that it would
be a wise idea to continue avoiding embracing a specific smart pointer
implementation.

Not using smart pointers in our API (neither the Qt's or the std:: ones)
allows each developer to use his own preferred solution with a minimal
effort. People might want to use boost smart pointers, SaferCPlusCplus,
or even their own handcrafted smart pointer templates. I don't think
that Qt should make a choice for them.

Ciao,
  Alberto


-- 
http://www.mardy.it - Geek in un lingua international
_______________________________________________
Development mailing list
Development@qt-project.org
https://lists.qt-project.org/listinfo/development

Reply via email to