I’m using a library with a defective operator<<, which I want to replace with my own version. It follows the idiom where ADL selects the overload based on the argument’s membership in the library’s namespace. Is there any way to cause C++ to select my own operator<< instead?
I’m using a library with a defective operator<< , which I want to replace
Share
One suboptimal solution is to declare a wrapper class around the library type.
A general implementation would look like this:
This is tested to work with expression templates. Note that if the override overload doesn’t match, the error message from GCC 4.7 is a red herring… it refers to an overload in
std::involving a stream rvalue reference: