I use vectors a lot in my programming, and generally to traverse a vector for an existing value I use std::find as in:
std::vector<int> foo;
std::vector<int>::iterator pos( std::find( foo.begin(), foo.end(), bar );
This is a real bore. So I went to deriving a template from std::vector to provide a find method:
template<class T>
class foovector : public std::vector<T>
{
public:
typename std::vector<T>::iterator find( const T& value )
{
return std::find( this->begin(), this->end(), value );
}
};
And so now I can do find's more naturally:
foovector<int> foo;
foovector<int>::iterator pos( foo.find( bar ) );
My question is that this seems such a natural and obvious extension to vector, so why isn't it part of the STL or even boost? I feel like I'm missing some Arcane Knowledge here.