Add support for non-default compare template argument in std::map wrappers

This commit is contained in:
William S Fulton 2018-10-09 19:44:00 +01:00
commit ca287ae13b
12 changed files with 234 additions and 230 deletions

View file

@ -25,14 +25,14 @@ namespace std {
typedef K key_type;
typedef T mapped_type;
map();
map(const map<K,T,C> &);
map(const map< K, T, C > &);
unsigned int size() const;
bool empty() const;
void clear();
%extend {
const T& get(const K& key) throw (std::out_of_range) {
std::map<K,T,C >::iterator i = self->find(key);
std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
return i->second;
else
@ -42,14 +42,14 @@ namespace std {
(*self)[key] = x;
}
void del(const K& key) throw (std::out_of_range) {
std::map<K,T,C >::iterator i = self->find(key);
std::map< K, T, C >::iterator i = self->find(key);
if (i != self->end())
self->erase(i);
else
throw std::out_of_range("key not found");
}
bool has_key(const K& key) {
std::map<K,T,C >::iterator i = self->find(key);
std::map< K, T, C >::iterator i = self->find(key);
return i != self->end();
}
}