[graphics/krita] /: Add a note about usage of CTAD for QVector in Krita
Dmitry Kazakov
null at kde.org
Fri Nov 21 12:44:54 GMT 2025
Git commit ba8268d608a2baffa1804d76657f8d74e2d59c1b by Dmitry Kazakov.
Committed on 21/11/2025 at 12:44.
Pushed by dkazakov into branch 'master'.
Add a note about usage of CTAD for QVector in Krita
tldr; do not use code like QVector({QPointF()}), use
QVector<QPointF>({QPointF()}) instead.
CC:kimageshop at kde.org
M +20 -0 HACKING
https://invent.kde.org/graphics/krita/-/commit/ba8268d608a2baffa1804d76657f8d74e2d59c1b
diff --git a/HACKING b/HACKING
index 6e90261df62..5fc5b90676d 100644
--- a/HACKING
+++ b/HACKING
@@ -271,6 +271,26 @@ The usage of timers, compressors and QTimer::singleShot()
ones, if their timeout is less or equal 20. Which can also consume all
the available precise timers.
+Class template argument deduction (CTAD) (since C++17)
+
+ C++17 allows automatical deduction of class template arguments for the class
+ constructors. I.e. you can write
+
+ QList list({QPointF(), QPointF(), QPointF()});
+
+ and template arguments for the QList template will be deduced automatically.
+
+ You can use this feature in new code, given the style of the whole file is
+ consistent.
+
+ WARNING for Qt6 and QVector:
+
+ Do **NOT** use CTAD for QVector until we switch to C++20! In Qt6 QVector is
+ declared as an alias for QList, and CTAD for aliases is a C++20 feature!
+
+ The code **will** compile with GCC on Linux even with `--std=c++17`, but
+ will fail to compile with Clang on Windows, Android and MacOS.
+
With Krita now supporting Python scripting, we need guidelines for these as well.
These guidelines are preliminary and may be further refined in the future.
More information about the kimageshop
mailing list