# STLAlgorithmExtensions/FindFirstLast

BOOST WIKI | STLAlgorithmExtensions | RecentChanges | Preferences | Page List | Links List

I have always wandering why STL does not provide following algorithms (std::string has them):

find_first_not_of - 2 versions find_last_of - 2 versions find_last_not_of - 2 versions

but only 2 versions of find_first_of. May be I just missing the way how to implement them in terms of some other algorithms? If not I think it could be valuable to fill this gap.

They surely can be implemented in terms in some other algorithms, e.g. first_first_not_of would be written like:
```set<int> s;
something::iterator p = find(v.begin(), v.end(), not1(bind(&set<int>::count, &s)));
```
However, the real question is whether generic find_first_not_of is usefull: it supposedly will take a pair of iterators to denote the set of symbols looked for, which is OK for
``` string::size_type n = s.find_first_not_of(" \t\r\n");
```
but can be very inefficient in other situations. --People/Vladimir Prus
Find_first_of has the same efficiency problems but was considered useful. It seems natural to include find_first_not_of since it can not be implemented in that form by other algotithms.

The _last_ algorithms can be implemented in terms of the _first_ algorithms with the added inefficiency of reverse_iterator.

--John Potter

I have to wonder if this couldn't simply be implemented in terms of find_first() with a composed functor, something like:

find_first(a, b, not(one_of(" \t\r\n")));

Maybe a vector is a better way to think about the one_of() functor in this case?

--Jesse Williamson

BOOST WIKI | STLAlgorithmExtensions | RecentChanges | Preferences | Page List | Links List