From 369be6fac44a3c295c6df89ed97a7e8e0bc4556f Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 9 Jun 2018 18:02:42 +0200 Subject: [PATCH] Add support for std::map<> comparator template argument for Java Allow exporting maps using non-default comparison function, similar to what was done for C# back in 9efaf954c71118d41ba9bf43ed371bbe83093564 --- CHANGES.current | 3 +++ Lib/java/std_map.i | 10 +++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGES.current b/CHANGES.current index 70f13c05f..b24242a34 100644 --- a/CHANGES.current +++ b/CHANGES.current @@ -7,6 +7,9 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ Version 4.0.0 (in progress) =========================== +2018-06-09: vadz + [Java] Allow exporting std::map using non-default comparison function. + 2018-06-08: philippkraft [Python] Stop exposing _swigregister to Python. It's not useful for user Python code to call this, and it just clutters the diff --git a/Lib/java/std_map.i b/Lib/java/std_map.i index 2405571fa..a94a99576 100644 --- a/Lib/java/std_map.i +++ b/Lib/java/std_map.i @@ -18,21 +18,21 @@ namespace std { - template class map { + template > class map { public: typedef size_t size_type; typedef ptrdiff_t difference_type; typedef K key_type; typedef T mapped_type; map(); - map(const map &); + map(const map &); unsigned int size() const; bool empty() const; void clear(); %extend { const T& get(const K& key) throw (std::out_of_range) { - std::map::iterator i = self->find(key); + std::map::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::iterator i = self->find(key); + std::map::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::iterator i = self->find(key); + std::map::iterator i = self->find(key); return i != self->end(); } }