
Thorsten Ottosen wrote:
Jon Willesen wrote:
But it appears my compiler errors were caused by the removal of the comma operator in the class the list_of function returns. It appears this was intentional since the unit tests were changed, but the current documentation for list_of still indicates the comma operator is legal syntax, and operator+= still uses the comma syntax, so I'm a little confused.
My memory is weak in this respect, but I think I might have viewed the syntax as redundant.
Well, yes. But since I find the comma syntax more useful/convenient, the redundancy has a sufficient reason to exist IMO.
If you like the comma, you might write
data += "foo", "bar", "baz";
but that is not initialization.
Right - I often need to initialize global constants or complex data structures, so the += syntax won't always work for me.
I don't mind adding the operator again, it should be trivially defined, but I wonder if we removed it because it could actually create problems in some situations.
It seems to me that most arguments against overloading the comma operator would also apply to the += context. Here are a couple of threads I found on the topic: (http://tinyurl.com/7dg5m), and (http://tinyurl.com/9b2va). Do either of those jog your memory? Can anyone else come up with other examples? Neither objection seems sufficient to me to remove operator,. Lack of sequencing doesn't bother me because I'm clearly asking for initialization by calling list_of and should not expect sequencing. As for the second link, (list_of<int>(), (1, 2, 3)) looks sufficiently silly to me to dismiss. The only other thing I can think of that concerns me at all is if I'm trying to call a function that has been overloaded to take 1..N arguments using the preprocessor library or some other code generator. Then this code: func(list_of<string>(), "foo", "bar", "baz"); might compile successfully and pass four arguments to func when I really meant to pass one argument: func((list_of<string>(), "foo", "bar", "baz")); This particular combination of advanced techniques seems unlikely enough that I would still rather have the comma operator. Given no other objections, I would vote to have list_of's comma operator reinstated. -- Jon