Pair and multimap
I'm trying to use pair<X, Y> to add key/value pairs to a multimap. I'm not really used to using STL templates, and I can't figure out why this isn't working.
Some internet research has told me that this is the correct syntax. However, gcc says:
The Date class has <, >, and == overloaded. What did I do wrong?
multimap<Date, Event> eventMap;
Date d (7200);
Event e (....);
eventMap.insert (pair<Date, Event> (d, e));Some internet research has told me that this is the correct syntax. However, gcc says:
/usr/lib/gcc/i386-redhat-linux/4.3.0/../ ../../../include/c++/4.3.0/bits/stl_func tion.h: In member function ‘bool std::less<_Tp>::operator()(const _Tp&, const _Tp&) const [with _Tp = Date]’:
/usr/lib/gcc/i386-redhat-linux/4.3.0/../ ../../../include/c++/4.3.0/bits/stl_tree.h:1 168: instantiated from ‘typename std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::iterator std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_insert_equal(const _Val&) [with _Key = Date, _Val = std::pair<const Date, Event>, _KeyOfValue = std::_Select1st<std::pair<const Date, Event> >, _Compare = std::less<Date>, _Alloc = std::allocator<std::pair<const Date, Event> >]’
/usr/lib/gcc/i386-redhat-linux/4.3.0/../ ../../../include/c++/4.3.0/bits/stl_mult imap.h:408: instantiated from ‘typename std::_Rb_tree<_Key, std::pair<const _Key, _Tp>, std::_Select1st<std::pair<const _Key, _Tp> >, _Compare, typename _Alloc::rebind<std::pair<const _Key, _Tp> >::other>::iterator std::multimap<_Key, _Tp, _Compare, _Alloc>::insert(const std::pair<const _Key, _Tp>&) [with _Key = Date, _Tp = Event, _Compare = std::less<Date>, _Alloc = std::allocator<std::pair<const Date, Event> >]’
population.cc:170: instantiated from here
/usr/lib/gcc/i386-redhat-linux/4.3.0/../ ../../../include/c++/4.3.0/bits/stl_func tion.h:230: error: passing ‘const Date’ as ‘this’ argument of ‘bool Date::operator<(const Date&)’ discards qualifiersThe Date class has <, >, and == overloaded. What did I do wrong?
