From f8bf6531f0426804f3a80283d13af622da6339b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= Date: Fri, 3 Jan 2025 17:59:42 +0100 Subject: [PATCH] Require that the handle type used with QUniqueHandle is quite noexcept QUniqueHandle is intended for handle types or opaque pointers that are no-throw constructible, copyable, and assignable, and has nothrow comparison and relation operators. This patch ensures that this holds true, and makes most of the QUniqueHandle noexcept specifiers valid. This will make it easier to implement the comparison and relation operators in terms of the Qt comparison framework. Task-number: QTBUG-132507 Change-Id: Id9fc3fac72a2337541e49c3b4613b8fd082796af Reviewed-by: Thiago Macieira (cherry picked from commit 49f1877bbbb8f96d81144861558bdcc81e758a58) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit bded4bd5fcb319eb1e95f61a3b6bb80f555279a8) --- src/corelib/tools/quniquehandle_p.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/corelib/tools/quniquehandle_p.h b/src/corelib/tools/quniquehandle_p.h index 815d0768b06..c746e51fe72 100644 --- a/src/corelib/tools/quniquehandle_p.h +++ b/src/corelib/tools/quniquehandle_p.h @@ -22,6 +22,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -111,6 +112,19 @@ class QUniqueHandle { public: using Type = typename HandleTraits::Type; + static_assert(std::is_nothrow_default_constructible_v); + static_assert(std::is_nothrow_constructible_v); + static_assert(std::is_nothrow_copy_constructible_v); + static_assert(std::is_nothrow_move_constructible_v); + static_assert(std::is_nothrow_copy_assignable_v); + static_assert(std::is_nothrow_move_assignable_v); + static_assert(std::is_nothrow_destructible_v); + static_assert(noexcept(std::declval() == std::declval())); + static_assert(noexcept(std::declval() != std::declval())); + static_assert(noexcept(std::declval() < std::declval())); + static_assert(noexcept(std::declval() <= std::declval())); + static_assert(noexcept(std::declval() > std::declval())); + static_assert(noexcept(std::declval() >= std::declval())); QUniqueHandle() = default;