Subject: Re: [boost] [assignment] += for containers on right side
From: Lars Viklund (zao_at_[hidden])
Date: 2012-07-20 11:43:16
On Thu, Jul 19, 2012 at 06:00:42PM +0200, Jochen Wilhelmy wrote:
> is it possible to make += also work for containers on right side?
> int a;
> std::vector<int> b;
> std::list<int> c;
> std::vector<int> d;
> d += a,b,c,d;
I would rather not have such a functionality, at least not without extra
spelling around it. At a very minimum I'd expect some kind of
d += a,expand_range(b),expand_range(c);
d += a,expand_ranges(b,c);
d += flatten(a,b,c);
What if you have code that relies on an implicit conversion from those
container types to the element type of the left hand side. You would
suddenly and silently change the semantics of such code.
Beware changes of semantics, because you _will_ have people that
wittingly or unwittingly rely on them.
-- Lars Viklund | zao_at_[hidden]