From 4968f8418f65dca54078c3565de8db3b777686c4 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Wed, 21 Jun 2023 11:22:15 +0200 Subject: [PATCH] Document Q_NODISCARD_CTOR Found in API review. Amends 959800f6de137f6a77c7d5a2741a5bae0638cbd9. Pick-to: 6.6 Change-Id: I00877ce7030c638765b495089899c022deb31a27 Reviewed-by: Ivan Solovev --- src/corelib/global/qcompilerdetection.qdoc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/corelib/global/qcompilerdetection.qdoc b/src/corelib/global/qcompilerdetection.qdoc index e6aa8e66d46..5074d8f6c19 100644 --- a/src/corelib/global/qcompilerdetection.qdoc +++ b/src/corelib/global/qcompilerdetection.qdoc @@ -392,3 +392,21 @@ If this macro is used outside a function, the behavior is undefined. */ + +/*! + \macro Q_NODISCARD_CTOR + \relates + \since 6.6 + + \brief Expands to \c{[[nodiscard]]} on compilers that accept it on constructors. + + Otherwise it expands to nothing. + + Constructors marked as Q_NODISCARD_CTOR cause a compiler warning if a call + site doesn't use the resulting object. + + This macro is exists solely to prevent warnings on compilers that don't + implement the feature. If your supported platforms all allow \c{[[nodiscard]]} + on constructors, we strongly recommend you use the C++ attribute directly instead + of this macro. +*/