diff options
author | Marc Mutz <marc.mutz@qt.io> | 2023-01-09 15:42:01 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2023-01-10 01:32:49 +0100 |
commit | f6b026eed1a4a3441ba9b1b92a9eaf2c17d69253 (patch) | |
tree | f6e8b71c6eb737ec78202e4902b5a1622ed1f034 /src/corelib/tools/qpair.h | |
parent | d55d93629b3a7616ceeae078ebfc90dc8598661b (diff) |
Move QTypeInfo<std::pair> from qpair.h to qtypeinfo.h to avoid ODR violation
First off, this doesn't cost us anything, because std::pair is defined
in <utility>, which qglobal.h unconditionally includes in C++ TUs.
More importantly, it prevents ODR violations: when a TU includes only
qtypeinfo.h, it will find std::pair<int, int> to be of Q_COMPLEX_TYPE,
in constrast with a TU which includes qpair.h, which will find it to
be of Q_PRIMITIVE_TYPE instead.
[ChangeLog][QtCore][QTypeInfo] The QTypeInfo for std::pair/QPair will
now be correct even if qpair.h hasn't been included, fixing an
One-Definition-Rule (ODR) violation.
Pick-to: 6.5 6.4 6.2
Change-Id: I51f579c123183af25aac9f0ffcf077f752848fb1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools/qpair.h')
-rw-r--r-- | src/corelib/tools/qpair.h | 3 |
1 files changed, 0 insertions, 3 deletions
diff --git a/src/corelib/tools/qpair.h b/src/corelib/tools/qpair.h index 75efaed3cf..8070ca0175 100644 --- a/src/corelib/tools/qpair.h +++ b/src/corelib/tools/qpair.h @@ -22,9 +22,6 @@ constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) return std::make_pair(std::forward<T1>(value1), std::forward<T2>(value2)); } -template<class T1, class T2> -class QTypeInfo<std::pair<T1, T2>> : public QTypeInfoMerger<std::pair<T1, T2>, T1, T2> {}; - QT_END_NAMESPACE #endif // QPAIR_H |