summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qpermissions.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2023-01-12 10:50:48 +0100
committerMarc Mutz <marc.mutz@qt.io>2023-01-13 14:38:17 +0100
commit6ac9d46a36f1b6b921efdcb47d7b7241d2396897 (patch)
tree9b8f75fce7f45cc08d4e6e8963d2fd26b16dc4fa /src/corelib/kernel/qpermissions.cpp
parent66235481043d85e4f51a216cf2ad3bb895ea7842 (diff)
QPermission: don't hide SFINAE constraints
Like done elsewhere (e.g. in QStringView), formulate the constaint in if_x<T> = true from, and let qdoc see it. Then document the constraint in prose, too. As a drive-by, use C++17 variable templates instead of std::bool_value, and document that data() returns a default-constructed T on failure (which is indistinguishable from a successful call that happens to return a default-constructed T, so we should probably return an optional<T> here, but that's orthogonal to the change at hand). Pick-to: 6.5 Change-Id: I0584ce3f4febd619d3966afeb6244b11b167cd42 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Diffstat (limited to 'src/corelib/kernel/qpermissions.cpp')
-rw-r--r--src/corelib/kernel/qpermissions.cpp22
1 files changed, 16 insertions, 6 deletions
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 <typename Type> QPermission::QPermission(const Type &type)
+ \fn template <typename T, if_permission<T>> 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 <typename Type> Type QPermission::data() const
+ \fn template <typename T, if_permission<T>> 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
*/
/*!