Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qtypeinfo.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2022 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\headerfile <QTypeInfo>
6
\inmodule QtCore
7
\ingroup funclists
8
\brief Macros for specifying information about custom types.
9
*/
10
11
/*!
12
\macro Q_DECLARE_TYPEINFO(Type, Flags)
13
\relates <QTypeInfo>
14
15
You can use this macro to specify information about a custom type
16
\a Type. With accurate type information, Qt's \l{Container Classes}
17
{generic containers} can choose appropriate storage methods and
18
algorithms.
19
20
\a Flags can be one of the following:
21
22
\list
23
\li \c Q_PRIMITIVE_TYPE specifies that \a Type requires no
24
operation to be performed in order to be properly destroyed,
25
and that it is possible to use memcpy() in order to create a
26
valid independent copy of an object.
27
\li \c Q_RELOCATABLE_TYPE specifies that \a Type has a constructor
28
and/or a destructor, but it can still be \e{relocated} in memory
29
by using \c memcpy().
30
\li \c Q_MOVABLE_TYPE is the same as \c Q_RELOCATABLE_TYPE. Prefer to use
31
\c Q_RELOCATABLE_TYPE in new code. Note: despite the name, this
32
has nothing to do with move constructors or C++ move semantics.
33
\li \c Q_COMPLEX_TYPE (the default) specifies that \a Type has
34
constructors and/or a destructor and that it may not be moved
35
in memory.
36
\endlist
37
38
Example of a "primitive" type:
39
40
\snippet code/src_corelib_global_qglobal.cpp 38
41
42
An example of a non-POD "primitive" type is QUuid: Even though
43
QUuid has constructors (and therefore isn't POD), every bit
44
pattern still represents a valid object, and memcpy() can be used
45
to create a valid independent copy of a QUuid object.
46
47
Example of a relocatable type:
48
49
\snippet code/src_corelib_global_qglobal.cpp 39
50
51
Qt will try to detect the class of a type using standard C++ type traits;
52
use this macro to tune the behavior.
53
For instance many types would be candidates for Q_RELOCATABLE_TYPE despite
54
not being trivially-copyable.
55
*/
qtbase
src
corelib
global
qtypeinfo.qdoc
Generated on
for Qt by
1.14.0