Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-07-07 10:56:02

"Andrei Alexandrescu \(See Website for Email\)" <andrewalex_at_[hidden]> writes:

> "Vladimir Prus" <ghost_at_[hidden]> wrote in message
> news:ccg4pu$pns$
>> 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.

Well, it might.

But then, the user knows he's using the initialization library, and
operator, has a different meaning in that context, just like
operator<< means something else in the context of a Spirit gramar.

Dave Abrahams
Boost Consulting

Boost list run by bdawes at, gregod at, cpdaniel at, john at