QScoped(Array)Pointer: remove the class-level [[nodiscard]]

It was used as a work-around for constructor-level [[nodiscard]]
missing in C++17, but a) compilers are free to implement [[nodiscard]]
for constructors in C++17 (P1771 was not considered a normative
change, just a clarification of the existing wording), and b) prevents
useful code that returns such types from functions.

Pick-to: 6.6
Task-number: QTBUG-104164
Change-Id: I440b418d58e86118e84689adb06d239ca598afcc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
bb10
Marc Mutz 2023-06-16 08:29:56 +02:00
parent c823bc2fdb
commit 21c344a221
1 changed files with 2 additions and 2 deletions

View File

@ -67,7 +67,7 @@ typedef QScopedPointerObjectDeleteLater<QObject> QScopedPointerDeleteLater;
#endif
template <typename T, typename Cleanup = QScopedPointerDeleter<T> >
class [[nodiscard]] QScopedPointer
class QScopedPointer
{
public:
explicit QScopedPointer(T *p = nullptr) noexcept : d(p)
@ -187,7 +187,7 @@ private:
};
template <typename T, typename Cleanup = QScopedPointerArrayDeleter<T> >
class [[nodiscard]] QScopedArrayPointer : public QScopedPointer<T, Cleanup>
class QScopedArrayPointer : public QScopedPointer<T, Cleanup>
{
template <typename Ptr>
using if_same_type = typename std::enable_if<std::is_same<typename std::remove_cv<T>::type, Ptr>::value, bool>::type;