From: Andrei Alexandrescu \(See Website for Email\) (andrewalex_at_[hidden])
Date: 2004-07-07 10:19:55


"Vladimir Prus" <ghost_at_[hidden]> wrote in message
news:ccg4pu$pns$1_at_sea.gmane.org...
> I think in this context it's more or less harmless. One can do:
>
> vector<int> v;
> v += 1, 2, 3;
>
> but the += operator is only defined for specific containers, and it's not
> defined for vector by default. So there's little risk that user will
> inadvertently use it, meaning something else.

I was worried more (only) about the order of evaluation. If I understand
correctly, if I call:

v += foo(), bar();

the code will be same as:

operator,(operator+=(v, foo()), bar());

so the order of executing foo() and bar() is unspecified. This might
surprise the user.

Andrei