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 <robert.griebl@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
bb10
Lars Knoll 2020-12-01 14:43:53 +01:00
parent c4d488eeb9
commit 5494f0af32
1 changed files with 2 additions and 1 deletions

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: