Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2001-08-09 15:01:41

string result = accumulate(strs.begin()+1, strs.end, strs.front(),
(the more complicated expression since we don't want the "|" if there
is only one element);

Now, what I WOULD like is an accumulate-like algorithm which takes
functors which take the first argument as a non-const reference, and
actually modify the first object. It needs to copy on the way in and
the way out, but not intermediate temporaries. This would avoid a bunch
of maybe needless copying, especially for string functions:

struct combiner {
  combiner(const string &separator): mSep(separator);
  string & operator()(string &a, const string &b) {
        a += separator;
        a += b;
        return a;

What about LL?

   string result = accumulate(strs.begin() + 1, strs.end(), strs.front(),
                    ll::_1 += ll::constant("|"), _a += ll::_2 );



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