[Development] The future of smart pointers in Qt API

Alberto Mardegan mardy at users.sourceforge.net
Tue Feb 4 16:16:46 CET 2020


On 04/02/20 16:55, Vitaly Fanaskov wrote:
> But if you see API like this:
> 
> std::unique_ptr<Foo> someAPI();
> 
> You have much more information about managed object just by reading the 
> code. This is also much easier to understand what can or cannot be done 
> with the returned value in the example above.

True. I still think that the benefit it's not worth the imposition of
smart pointers. Annotations could be used on the header files, and qdoc
could be smart enough to present them in a clear way.

> There also were good arguments about exceptions. We shouldn't forget 
> that Qt can be used with a program that uses exceptions.

But this seems to be a point for *not* using std::, isn't it? We also
want Qt to be used with a program that does *not* use exceptions.

What would happen if one of the STL classes publicly used in the Qt API
gained some method that can throw an exception (not just in OOM cases,
but as part of a common scenario)?

Ciao,
  Alberto

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


More information about the Development mailing list