On 31/05/2015 22:48, Rob Stewart wrote:
On May 31, 2015 1:08:09 AM EDT, Gennadiy Rozental
wrote: Apparently most types are streamable.
I wouldn't assume that.
I often define stream operators in the unit tests rather than in the "real" code for types that I do not intend to be streamable in practice but for which I want to have useful error messages printed on test failure. Occasionally that leads me to move the operator into the real code later on, when it turns out that I also want to log it or something. (This is regardless of which unit test framework is in use -- when printing equality failures, most use either operator<< or some custom specializable/overridable method that usually falls back to operator<< if not otherwise overridden.) There are of course lots of types that it doesn't make sense to ever stream (because they're not value-like), but those rarely implement operator== either, so it's not an issue.