Boost logo

Boost :

From: John E. Potter (jpotter_at_[hidden])
Date: 2001-06-12 14:35:39


On Tue, 12 Jun 2001, Beman Dawes wrote:

> I'd like to see a Boost string algorithms library.

The STL really sux doesn't it? Why not trash it?

> string & erase_all( string & s, const string & search );

template <class Fiter1, class Fiter2, class Oiter>
Oiter remove_copy (Fiter1 first1, Fiter1 last1, Fiter2 first2,
      Fiter2 last2, Oiter result) {
   typename iterator_traits<Fiter2>::difference_type
         len(distance(first2, last2));
   while (first1 != last1) {
      Fiter1 pos(search(first1, last1, first2, last2));
      result = copy(first1, pos, result);
      if (pos != last1)
         advance(pos, len);
      first1 = pos;
      }
   return result;
   }
int main () {
   string s("How now own brown cow"), p("ow");
   cout << s << endl;
   s.erase(remove_copy(s.begin(), s.end(), p.begin(), p.end(), s.begin()),
         s.end());
   cout << s << endl;
   int data[] = { 1, 2, 3, 4, 2, 1, 2, 3 };
   vector<int> v(data, data + 8);
   v.erase(remove_copy(v.begin(), v.end(), data, data + 3,
         ostream_iterator<int>(cout));
   cout << endl;
   }

> Now the tricky part - users would also like options:
>
> The "search" argument to be a regular expression.

Can they be integrated? On other types?

> The "search" comparison to be treated as case insensitive.

The compare template parameter?

Throwing-a-bucket-of-cold-waterly yours,
John


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