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.

Fixes: QTBUG-88990
Change-Id: I5d687576c6d926823dd0f1fec0743e877ae271af
Reviewed-by: Robert Griebl <robert.griebl@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 5494f0af323a42390f9375c75e9298290ecb7662)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Lars Knoll 2020-12-01 14:43:53 +01:00 committed by Qt Cherry-pick Bot
parent 54c18ea30a
commit 35b2e74fd7

View File

@ -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: