Boost logo

Boost :

Subject: Re: [boost] [assignment] += for containers on right side
From: Amir Ansari (amir.ansari80_at_[hidden])
Date: 2012-07-20 07:12:02


std::valarray provides this type of functionality. If you need to use a vector, you can write your own operator overload: template<class T> std::vector<T> & operator += (std::vector<T> & l, int r) {     std::for_each(l.begin(), l.end(), [r] (T & t) { t += r; });     return l; } Hope this helps. ________________________________ From: Kai Schroeder <kaischroeder3_at_[hidden]> To: boost_at_[hidden] Sent: Friday, July 20, 2012 3:38 PM Subject: Re: [boost] [assignment] += for containers on right side Hi Digi, as far as I know there is no such functionality in Boost. To implement this I would take inspirations from boost::assign and make use of boost::range. Regards, Kai On 7/19/12, Jochen Wilhelmy <jochen.wilhelmy_at_[hidden]> wrote: > Hi! > > is it possible to make += also work for containers on right side? > i.e. > int a; > std::vector<int> b; > std::list<int> c; > std::vector<int> d; > d += a,b,c,d; > > this would be similar to strings where += at least works with one string > on the right side. > > -Jochen > > > _______________________________________________ > Unsubscribe & other changes: > http://lists.boost.org/mailman/listinfo.cgi/boost > _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk