diff options
Diffstat (limited to 'src/corelib/global/qtypeinfo.qdoc')
-rw-r--r-- | src/corelib/global/qtypeinfo.qdoc | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/corelib/global/qtypeinfo.qdoc b/src/corelib/global/qtypeinfo.qdoc new file mode 100644 index 0000000000..75a92da197 --- /dev/null +++ b/src/corelib/global/qtypeinfo.qdoc @@ -0,0 +1,48 @@ +// Copyright (C) 2022 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \macro Q_DECLARE_TYPEINFO(Type, Flags) + \relates <QTypeInfo> + + You can use this macro to specify information about a custom type + \a Type. With accurate type information, Qt's \l{Container Classes} + {generic containers} can choose appropriate storage methods and + algorithms. + + \a Flags can be one of the following: + + \list + \li \c Q_PRIMITIVE_TYPE specifies that \a Type requires no + operation to be performed in order to be properly destroyed, + and that it is possible to use memcpy() in order to create a + valid independent copy of an object. + \li \c Q_RELOCATABLE_TYPE specifies that \a Type has a constructor + and/or a destructor, but it can still be \e{relocated} in memory + by using \c memcpy(). + \li \c Q_MOVABLE_TYPE is the same as \c Q_RELOCATABLE_TYPE. Prefer to use + \c Q_RELOCATABLE_TYPE in new code. Note: despite the name, this + has nothing to do with move constructors or C++ move semantics. + \li \c Q_COMPLEX_TYPE (the default) specifies that \a Type has + constructors and/or a destructor and that it may not be moved + in memory. + \endlist + + Example of a "primitive" type: + + \snippet code/src_corelib_global_qglobal.cpp 38 + + An example of a non-POD "primitive" type is QUuid: Even though + QUuid has constructors (and therefore isn't POD), every bit + pattern still represents a valid object, and memcpy() can be used + to create a valid independent copy of a QUuid object. + + Example of a relocatable type: + + \snippet code/src_corelib_global_qglobal.cpp 39 + + Qt will try to detect the class of a type using standard C++ type traits; + use this macro to tune the behavior. + For instance many types would be candidates for Q_RELOCATABLE_TYPE despite + not being trivially-copyable. +*/ |