From b8b75cdcfa71189c7726607be7b66d0ddeaae372 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Mon, 9 Nov 2020 18:01:59 +0100 Subject: [PATCH] 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 Pick-to: 5.15 5.12 Reviewed-by: Lars Knoll --- src/corelib/global/qglobal.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 424b8b3ac4d..48eb5b4567c 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3971,8 +3971,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_RELOCATABLE_TYPE specifies that \a Type has a constructor and/or a destructor but can be moved in memory using \c memcpy().