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
qobject_impl.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QOBJECT_H
6#error Do not include qobject_impl.h directly
7#include <QtCore/qobjectdefs_impl.h>
8#endif
9
10#if 0
11#pragma qt_sync_skip_header_check
12#pragma qt_sync_stop_processing
13#endif
14
15#include <QtCore/qmetatype.h>
16
17QT_BEGIN_NAMESPACE
18
19
20namespace QtPrivate {
21 namespace { struct UniqueType; }
22 /*
23 Logic to statically generate the array of qMetaTypeId
24 ConnectionTypes<FunctionPointer<Signal>::Arguments>::types() returns an array
25 of int that is suitable for the types arguments of the connection functions.
26
27 The array only exist if all the types are valid for QMetaType, detected
28 using qTryMetaTypeInterfaceForType(). If any type is not valid at this
29 point (non-const references and forward-declared types), the function
30 returns nullptr. If the issue is a forward-declared type, the function
31 can be used in a queued connection if the type is registered elsewhere
32 before the signal is emitted. If the type is a non-const reference, it
33 cannot be use in queued connections at all.
34 */
35 template <typename... Args> struct ConnectionTypesHelper
36 {
37 static const int *types()
38 {
39 if constexpr ((TypeIsSuitableForMetaType<Args, UniqueType> && ...)) {
40 static const int t[] = { qMetaTypeId<Args>()..., 0 };
41 return t;
42 } else {
43 return nullptr;
44 }
45 }
46 };
47
48 template <typename ArgList> struct ConnectionTypes;
49 template <> struct ConnectionTypes<List<>>
50 { static const int *types() { return nullptr; } };
51 template <typename... Args> struct ConnectionTypes<List<Args...>>
52 : public ConnectionTypesHelper<typename MetatypeDecay<Args>::type...>
53 {
54 };
55}
56
57
58QT_END_NAMESPACE