Hi, quick question. How do you get operator== working with std::find? I got it working for std::list::remove, but using std::find to grab the iterator to use for std::list::erase fails.
Code:
error: no match for ‘operator==’ in ‘__first.std::_List_iterator<_Tp>::operator* [with _Tp = klass, _Tp& = klass&]() == __val’
note: candidates are: bool klass::operator==(klass&)
note: bool klass::operator==(const klass&)
note: bool klass::operator==(klass&) const
note: bool klass::operator==(const klass&) const
stl_algo.h
Code:
/// This is an overload used by find() for the Input Iterator case.
template<typename _InputIterator, typename _Tp>
inline _InputIterator
__find(_InputIterator __first, _InputIterator __last,
const _Tp& __val, input_iterator_tag)
{
while (__first != __last && !(*__first == __val)) // error here
++__first;
return __first;
}
So __val is klass&, and *__first is.. iterator dereferenced into klass&?
What's the problem then?
Thanks!