
From: brangdon@cix.compulink.co.uk (Dave Harris)
In-Reply-To: <cch4as$941$1@sea.gmane.org> andrewalex@hotmail.com (Andrei Alexandrescu \(See Website for Email\)) wrote (abridged):
I was worried more (only) about the order of evaluation.
v += foo(), bar();
Unless I'm mistaken, there is but one sequence point in such an expression, regardless of whether you overload operator,. Thus, any expression using commas must be understood to have indeterminant order of evaluation. Consider: int v[] = { foo(), bar() }; Doesn't this exhibit the same problem? If so, the problem is only that an initialization library exposes the problem to more daylight.
I don't think order of evaluation is sacred. However, I am also not keen on using comma for this. I'd rather use operator<<().
v << foo() << bar();
This is partly because comma is so small its easy to overlook, partly because it is used for so many other common things, and partly because I think the semantics of operator<<() fit better here. "Append these items to that stream or container, with conversion or formatting if appropriate."
I don't like that. It suggests formatted insertion rather than initialization. As you point out, conversion is possible, but one can't overload operator<< to customize the initialization. Thus, it doesn't fit neatly with IOStreams. -- Rob Stewart stewart@sig.com Software Engineer http://www.sig.com Susquehanna International Group, LLP using std::disclaimer;