Define operator<<
in the proper class namespaces to fix ADL.
#990
Labels
bug
Something isn't working
operator<<
in the proper class namespaces to fix ADL.
#990
Description
The
operator<<
implementations have been defined in the global namespace instead of the class namespace.See for example:
libdatachannel/include/rtc/peerconnection.hpp
Lines 123 to 130 in eff6413
This breaks ADL based discovery of operators. I run into this issue when trying to format
libdatachannel
types usingfmt 10.0.0
.An example of broken ADL operator discovery
Here is a very basic reproducer to demonstrate broken ADL based discovery: https://godbolt.org/z/Gx8sb3eb8
This is the crude fix I'm using to enable printing on my side: https://godbolt.org/z/TK3bf786E
Here is a proper fix for this example: https://godbolt.org/z/bPvj6vqPG
Expected
This is the expected code to make
libdatachannel
types formattable usingfmt
.Workaround
This is actually needed to make the
libdatachannel
type formattable byfmt
.Suggested Fix
Please move all the
std::ostream &operator<<(std::ostream &os, T t)
definitions into the namespace where the corresponding type is defined.The text was updated successfully, but these errors were encountered: