smart pointers
Xaver Hugl
xaver.hugl at gmail.com
Tue May 17 13:34:14 BST 2022
Hello,
I noticed that in KWin we use a lot of smart pointers and we mix Qt and C++
standard library ones quite a lot. Judging by a few searches in frameworks
repositories, it's a similar mix there.
I'd like to propose that going forwards we use C++ standard library smart
pointers in new code and also port old code (where possible) away from Qt
smart pointers, for the following reasons:
- it increases consistency, making code a little bit easier to read
- in the general C++ community, smart pointers from the standard librariy
are much more well known, which should make it a little bit easier for new
contributors to settle in
- std::unique_ptr allows to properly express ownership transfers with move
semantics, which QScopedPointer does not support
- std::shared_ptr is more efficient than QSharedPointer, it has half the
overhead on reference changes
What do you all think?
Greetings,
Xaver
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20220517/fff819d2/attachment.htm>
More information about the Kde-frameworks-devel
mailing list