
In-Reply-To: <200407072103.i67L3Jk28273@tesh.systems.susq.com> stewart@sig.com (Rob Stewart) wrote (abridged):
v << foo() << bar();
I don't like that. It suggests formatted insertion rather than initialization.
It's not intended to be initialisation. It does a push_back(), so you can do it at any time and not just on empty vectors. I guess I'd pick a different name for the library, but as written that includes += so it too is not just for initialisation. As I said, I don't think formatting is an essential characteristic of operator<<(). It happens to be necessary for streams because they are text oriented. The serialisation library uses operator<<() without formatting.
As you point out, conversion is possible, but one can't overload operator<< to customize the initialization.
Why not? vector<Foo> &operator<<( vector<Foo> &v, const Bar &bar ) { return v << bar.toFoo(); // Or whatever conversion you want. } Or whatever the right types are.
Thus, it doesn't fit neatly with IOStreams.
It's not polymorphic with them, but I think it fits about as neatly as the serialisation library. -- Dave Harris, Nottingham, UK