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 <thiago.macieira@intel.com> (cherry picked from commit 49f1877bbbb8f96d81144861558bdcc81e758a58) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> (cherry picked from commit bded4bd5fcb319eb1e95f61a3b6bb80f555279a8)
This commit is contained in:
parent
872ecc4e37
commit
f8bf6531f0
@ -22,6 +22,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -111,6 +112,19 @@ class QUniqueHandle
|
||||
{
|
||||
public:
|
||||
using Type = typename HandleTraits::Type;
|
||||
static_assert(std::is_nothrow_default_constructible_v<Type>);
|
||||
static_assert(std::is_nothrow_constructible_v<Type>);
|
||||
static_assert(std::is_nothrow_copy_constructible_v<Type>);
|
||||
static_assert(std::is_nothrow_move_constructible_v<Type>);
|
||||
static_assert(std::is_nothrow_copy_assignable_v<Type>);
|
||||
static_assert(std::is_nothrow_move_assignable_v<Type>);
|
||||
static_assert(std::is_nothrow_destructible_v<Type>);
|
||||
static_assert(noexcept(std::declval<Type>() == std::declval<Type>()));
|
||||
static_assert(noexcept(std::declval<Type>() != std::declval<Type>()));
|
||||
static_assert(noexcept(std::declval<Type>() < std::declval<Type>()));
|
||||
static_assert(noexcept(std::declval<Type>() <= std::declval<Type>()));
|
||||
static_assert(noexcept(std::declval<Type>() > std::declval<Type>()));
|
||||
static_assert(noexcept(std::declval<Type>() >= std::declval<Type>()));
|
||||
|
||||
QUniqueHandle() = default;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user