Получаю ошибку в коде:
| Код | /usr/lib/gcc/i686-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h: In function '_InputIterator std::__find(_InputIterator, _InputIterator, const _Tp&, std::input_iterator_tag) [with _InputIterator = std::_Rb_tree_iterator<std::pair<const call_id, int> >, _Tp = call_id]': /usr/lib/gcc/i686-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h:4209:45: instantiated from '_IIter std::find(_IIter, _IIter, const _Tp&) [with _IIter = std::_Rb_tree_iterator<std::pair<const call_id, int> >, _Tp = call_id]' main.c:70:95: instantiated from here /usr/lib/gcc/i686-pc-linux-gnu/4.5.4/include/g++-v4/bits/stl_algo.h:131:7: error: no match for 'operator==' in '__first.std::_Rb_tree_iterator<_Tp>::operator* [with _Tp = std::pair<const call_id, int>, _Tp& = std::pair<const call_id, int>&]() == __val'
|
Пришлось выделить проблемный блок в тестовую программу, не могу понять в чем дело, оператор == есть. Помогите найти ошибку.
| Код | struct call_id {
bool operator<(const call_id &other) const { unsigned cnt = 0; while(cnt <= 16 && other.guid[cnt] < guid[cnt]) { cnt ++; }; if (cnt > 16) return true; return false; }
bool operator==(const call_id &other) const { return !strncmp((const char *)guid[0], (const char *)other.guid[0], 16); }
unsigned char guid[16]; };
typedef std::map<call_id, int> node_t; typedef std::map<int, node_t > sess_t;
std::map< int, std::map<call_id, int> > sessions; bool GetSession(int key, int &ptr, call_id guid) { sess_t::iterator it = sessions.find(key); if (it == sessions.end()) { return false; }; std::map<call_id, int> nodes_map = it->second; std::map<call_id, int>::iterator sess_it = std::find(nodes_map.begin(), nodes_map.end(), guid); // ЗДЕСЬ ОШИБКА if (sess_it != it->second.end()) { ptr = sess_it->second; return true; } else { } return false; };
int main() { int ptr; call_id guid; GetSession(20, ptr, guid); return 0; }
|
|