diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-06-21 11:58:50 +0200 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2023-06-30 12:52:03 +0000 |
commit | 410b57380ddb20d91b960c075eead80d8f17c76d (patch) | |
tree | 19099a979df5717ece4402de512f89c2ab2ef6b3 | |
parent | 68c32ef9724ce81e3df7b519efd95983e4d2ce69 (diff) |
[normative] Update QUIP-0019 for C++20 [[nodiscard("reason")]]
Fixes: QTBUG-114767
Change-Id: I8f6340d2baa665c7b9767889ff5d1d798a0fe6de
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | quip-0019-nodiscard-policy.rst | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/quip-0019-nodiscard-policy.rst b/quip-0019-nodiscard-policy.rst index ee09624..66e43bf 100644 --- a/quip-0019-nodiscard-policy.rst +++ b/quip-0019-nodiscard-policy.rst @@ -42,6 +42,9 @@ Version History - Since Qt 6.6, we can use ``Q_NODISCARD_CTOR`` to apply ``[[nodiscard]]`` to contructors, too. +- Since Qt 6.7, we have access to C++20 ``[[nodiscard("reason")]]`` + via ``Q_NODISCARD_X`` and ``Q_NODISCARD_CTOR_X``. + Policy ------ @@ -53,6 +56,10 @@ document are to be interpreted as described in `RFC 2119 Unless mentioned otherwise, the following applies to both public and private Qt C++ APIs. +Unless mentioned otherwise, whenever ``[[nodiscard]]`` or +``Q_NODISCARD_CTOR`` are mentioned below, it SHALL be read as +including ``Q_NODISCARD_X`` and ``Q_NODISCARD_CTOR_X`` respectively. + Constructors ```````````` @@ -100,17 +107,6 @@ Whole Classes wholesale at the moment. If there is enough demand, this may be worked around in the future. -C++20 ``[[nodiscard("reason")]]`` -````````````````````````````````` - -Qt currently does not require C++20, and does not offer a macro -implementing this feature, so we cannot use it in the code base, -unless guarded by a feature check macro. - -If and when such a macro is added, it SHALL be named -``Q_NODISCARD_X``, not ``Q_REQUIRED_RESULT_X``. - - Formatting ---------- @@ -149,6 +145,9 @@ Formatting header diff easier to read in API diffs at the cost of somewhat more vertical space needed for the declaration going forward. +4. The ``_X`` variants and ``[[nodiscard("reason")]]`` SHOULD always + be placed on a separate line, because they tend to be long + themselves. References ---------- @@ -158,3 +157,5 @@ References .. `"[[nodiscard]] for ctors", Peter Sommerlad: https://wg21.link/p1771`_ .. `GCC bug preventing class-level ``[[nodiscard]]`` on exported classes: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96117`_ + +.. `"[[nodiscard("should have a reason")]]", JeanHeyd Meneide, Isabella Muerte: https://wg21.link/p1301`_ |