Commit c2a2c4c8 authored by Daniel Teske's avatar Daniel Teske
Browse files

Coding guidelines: Add various C++11 features



Change-Id: I9d3ca28bf8d5d04e04464757420a3c8e30f5dac0
Reviewed-by: default avatarLeena Miettinen <riitta-leena.miettinen@theqtcompany.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@theqtcompany.com>
parent 088e5b64
......@@ -890,6 +890,35 @@
const QVector<int> values = {1, 2, 3, 4, 5};
\endcode
\section3 Non-Static Data Member Initialization
Use non-static data member initialization for trivial initializations, except in public
exported classes.
\section3 Defaulted and Deleted Functions
Consider using \c{=default} and \c{=delete} to control the special functions.
\section3 Override
It is recommended to use the \c{override} keyword when overriding virtual functions. Do not
use virtual on overridden functions.
Make sure that a class uses \c{override} consistently, either for all overridden functions or
for none.
\section3 Nullptr
All compilers support \c{nullptr}, but there is no consensus on using it. If in doubt, ask
the maintainer of the module whether they prefer using \c{nullptr}.
\section3 Range-Based for-Loop
You may use range-based for-loops, but beware of the spurious detachment problem.
If the for-loop only reads the container and it is not obvious whether the
container is const or unshared, use \c{std::cref()} to ensure that the container
is not unnecessarily detached.
\section2 Using QObject
\list
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment