James said:
Because in practice, it's far too much work; in fact, in
practice, I'm not sure it's possible, at least not portably.
You've got to define the corresponding char_traits for <Foo>,
with an int_type as well as a char_type, and streampos and
streamoff. In practice, the templatization of iostream is a
disaster---about the only good thing you can say about it is
that it can be ignored.
Yes, that's exactly what my smiley said!
Having a templated basic_ostream<T> with a write(T*, ) member
function, it is obviously intended to write Ts and not much else.
Otherwise the write member function would have been templated too,
like template<class U> write(U, ).
For ostream we actually have something like that, it is just a
freestanding operator<<(ostream&, const Foo&) that the OP would have
to add. The potential performance difference of formatting the Foo
content is of course very unlikely to be noticed, if the application
does anything else that writing Foos.
Bo Persson