Есть код. Хочу найти элемент, подходящий по критериям, в списке используя средства STL.
C
struct Str
{
QString name;
int value;
};
bool isequal(const Str* str, const int val)
{ return str->value == val; }
...
QList<Str *> lst;
QList<Str *>::iterator iter =
find(lst.begin(), lst.end(), bind2nd(ptr_fun(isequal), 5));
При компиляции получаю ошибку. Что в моем коде не так?
/usr/include/c++/4.1.3/bits/stl_algo.h: In function ‘_RandomAccessIterator std::__find(_RandomAccessIterator, _RandomAccessIterator, const _Tp&, std::random_access_iterator_tag) [with _RandomAccessIterator = QList<Str*>::iterator, _Tp = std::binder2nd<std::pointer_to_binary_function<const Str*, int, bool> >]’:
/usr/include/c++/4.1.3/bits/stl_algo.h:316: instantiated from ‘_InputIterator std::find(_InputIterator, _InputIterator, const _Tp&) [with _InputIterator = QList<Str*>::iterator, _Tp = std::binder2nd<std::pointer_to_binary_function<const Str*, int, bool> >]’
main.cxx:25: instantiated from here
/usr/include/c++/4.1.3/bits/stl_algo.h:208: error: no match for ‘operator==’ in ‘__first.QList<T>::iterator::operator* [with T = Str*]() == __val’