diff --git a/src/corelib/kernel/qpermissions.cpp b/src/corelib/kernel/qpermissions.cpp index 4d268463474..e95ebeeb824 100644 --- a/src/corelib/kernel/qpermissions.cpp +++ b/src/corelib/kernel/qpermissions.cpp @@ -229,22 +229,32 @@ Q_LOGGING_CATEGORY(lcPermissions, "qt.permissions", QtWarningMsg); */ /*! - \fn template QPermission::QPermission(const Type &type) + \fn template > QPermission::QPermission(const T &type) Constructs a permission from the given \l{typed permission} \a type. You do not need to construct this type explicitly, as the type is automatically used when checking or requesting permissions. + + This constructor participates in overload resolution only if \c T is one of + the \l{typed permission} classes: + + \annotatedlist permissions */ /*! - \fn template Type QPermission::data() const + \fn template > T QPermission::data() const - Returns the \l{typed permission} of type \c Type. + Returns the \l{typed permission} of type \c T. - The type must match the type that was originally used to request - the permission. Use type() for dynamically choosing which typed - permission to request. + If the type doesn't match the type that was originally used to request the + permission, returns a default-constructed \c T. Use type() for dynamically + choosing which typed permission to request. + + This function participates in overload resolution only if \c T is one of + the \l{typed permission} classes: + + \annotatedlist permissions */ /*! diff --git a/src/corelib/kernel/qpermissions.h b/src/corelib/kernel/qpermissions.h index 2a23412a221..361bc868b68 100644 --- a/src/corelib/kernel/qpermissions.h +++ b/src/corelib/kernel/qpermissions.h @@ -34,31 +34,24 @@ class QPermission Q_GADGET_EXPORT(Q_CORE_EXPORT) template - struct is_permission : public std::false_type {}; + static constexpr inline bool is_permission_v = false; template - struct is_permission : public std::true_type {}; + static constexpr inline bool is_permission_v = true; + template + using if_permission = std::enable_if_t, bool>; public: explicit QPermission() = default; -#ifdef Q_QDOC - template - QPermission(const Type &type); -#else - template ::value, bool> = true> + template = true> QPermission(const T &t) : m_data(QVariant::fromValue(t)) {} -#endif Qt::PermissionStatus status() const { return m_status; } QMetaType type() const { return m_data.metaType(); } -#ifdef Q_QDOC - template - Type data() const; -#else - template ::value, bool> = true> + template = true> T data() const { if (auto p = data(QMetaType::fromType())) @@ -66,7 +59,6 @@ public: else return T{}; } -#endif #ifndef QT_NO_DEBUG_STREAM friend Q_CORE_EXPORT QDebug operator<<(QDebug debug, const QPermission &);