OutputStream operator<< should be extensible

Unless I miss something, I can’t seem to make new classes cooperate with OutputStream operator<< because there is no way to extend those overrides of OutputStream.

out << "The object " << myObject << " is ready";

The way std:hash<> is openly extensible via template specialization is absolutely intriguing! I would like to see this pattern used more in Juce, so we can more easily make new classes cooperate with minimum verbosity and extra hoops.

Me stupid :woozy_face:

I missed that << also exists as a global operator that can be overridden anywhere. That’s pretty fine for extending it to more types.

OutputStream& operator<< (OutputStream& s, const var& o)
    s << o.toString();
    return s;

Still, I find template specialisation as a means for extending otherwise locked-down library classes very capable.