diff options
author | Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> | 2020-11-09 18:01:59 +0100 |
---|---|---|
committer | Volker Hilsheimer <volker.hilsheimer@qt.io> | 2020-11-10 13:29:42 +0000 |
commit | 126605f4e9044546d691817832682a5e981ec6cd (patch) | |
tree | 0e60f11e3b70c2ace462a421c55699d98396cff6 | |
parent | a3914e468d3bb9ef70862a0d81cb4fbb69c934cd (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 559ef4314c..6a361dcde0 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -4225,8 +4225,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 |