, , <algorithm>, , / . , ( , , ..), .
In your case, the general way to do this is:
template <typename Container>
typename Container::iterator find(Container& c,
typename Container::value_type const& v)
{
return std::find(c.begin(), c.end(), v);
}
template <typename Container>
typename Container::const_iterator find(Container const& c,
typename Container::value_type const& v)
{
return std::find(c.begin(), c.end(), v);
}
This can be used with any STL-compatible container.
Of course, it would be nice to adapt this through a concept to use a member function find, if available ...
source
share