From 5494f0af323a42390f9375c75e9298290ecb7662 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 1 Dec 2020 14:43:53 +0100 Subject: [PATCH] Add a note about where to declare the streaming operators Streaming operators for types used together with QMetaType should get declared in the same namespace as the type itself because of C++s ADL rules. Add a note about that to the documentation. Pick-to: 6.0 Fixes: QTBUG-88990 Change-Id: I5d687576c6d926823dd0f1fec0743e877ae271af Reviewed-by: Robert Griebl Reviewed-by: Fabian Kosmale --- src/corelib/kernel/qmetatype.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 21fd2d2aed..7298dc588f 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -245,7 +245,8 @@ Q_GLOBAL_STATIC(QMetaTypeCustomRegistry, customTypeRegistry) \note This method also registers the stream and debug operators for the type if they are visible at registration time. As this is done automatically in some places, it is strongly recommended to declare the stream operators for a type directly - after the type itself. + after the type itself. Because of the argument dependent lookup rules of C++, it is + also strongly recommended to declare the operators in the same namespace as the type itself. The stream operators should have the following signatures: