Merge branch 'vadz-java-map-comp'

* vadz-java-map-comp:
  Add support for std::map<> comparator template argument for Java

Conflicts:
	CHANGES.current
This commit is contained in:
William S Fulton 2018-10-09 07:09:06 +01:00
commit 8ddf24881a
2 changed files with 8 additions and 5 deletions

View file

@ -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) Version 4.0.0 (in progress)
=========================== ===========================
2018-06-09: vadz
[Java] #1274 Allow exporting std::map using non-default comparison function.
2018-10-04: wsfulton 2018-10-04: wsfulton
[Python] #1126 Fix C default arguments with -builtin and -fastunpack and -modernargs. [Python] #1126 Fix C default arguments with -builtin and -fastunpack and -modernargs.
Problem occurred when there is just one (defaulted) parameter in the parameter list. Problem occurred when there is just one (defaulted) parameter in the parameter list.

View file

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