[Development] The future of smart pointers in Qt API

Alberto Mardegan mardy at users.sourceforge.net
Fri Jan 31 20:21:33 CET 2020

Old man here:

On 31/01/20 13:07, Vitaly Fanaskov wrote:
> But how to use them in the API and which way is preferable is still 
> unclear. There are two main options we have:
> 1) Use std::*  smart pointers as-is.
> 2) Add Qt-style wrappers around std::* smart pointers and move old 
> implementations of Qt smart pointers to the Qt5Compact module.


I still have trouble understanding why std::unique_ptr is called like
this, whereas I could immediately understand what QScopedPointer does
even before reading its documentation.

> Another thing to discuss is whether we should use raw pointers in the 
> API at all or not. There are a few options again:
> 1) Yes
> 2) No. Use “modern” approaches instead (pass mandatory dependencies by 
> either reference or const reference when using smart pointers makes no 
> sense, use something optional-like or tuples to return extra data from 
> functions, and so on)
> 3) Mix 1 and 2.

1. (though of course, we should also use smart pointers where they bring
a clear advantage)


http://www.mardy.it - Geek in un lingua international

More information about the Development mailing list