diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-11-09 18:01:59 +0100 |
---|---|---|
committer | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-11-10 09:31:54 +0000 |
commit | 06799b58dd0e9a2f637e6e21949390e3b2b17733 (patch) | |
tree | 9eea6cf6a58cf8f9a3cef16cf8bc96f33613c8b3 | |
parent | 531a53c796a20fbeeb55536330ec718ef2bb7cb2 (diff) |
Q_PRIMITIVE_TYPE: improve the documentation
A key piece of information missing from Q_PRIMITIVE_TYPE
documentation is that for them value initialization must equal
memset()ting with zeroes. A type like QPoint is primitive
because `QPoint p;` is initialized to (0, 0), but a type like
QSize is movable (and NOT primitive) because `QSize s;` is
actually initialized to (-1, -1). Amend the docs.
Change-Id: I121684810da46be5d0579c7d3de945149390a32a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
(cherry picked from commit b8b75cdcfa71189c7726607be7b66d0ddeaae372)
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
-rw-r--r-- | src/corelib/global/qglobal.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 01f534cc0f..51b8379b3d 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -4031,8 +4031,9 @@ bool qunsetenv(const char *varName) \list \li \c Q_PRIMITIVE_TYPE specifies that \a Type is a POD (plain old data) type with no constructor or destructor, or else a type where - every bit pattern is a valid object and memcpy() creates a valid - independent copy of the object. + every bit pattern is a valid object; memset()ting memory to zero + creates a value-initialized instance of the type; and memcpy()ing + creates a valid independent copy of an object. \li \c Q_MOVABLE_TYPE specifies that \a Type has a constructor and/or a destructor but can be moved in memory using \c memcpy(). Note: despite the name, this has nothing to do with move |