Add simple std::set<> typemaps too

This is similar to the previous commit for std::map<>.
This commit is contained in:
Vadim Zeitlin 2021-10-07 14:19:39 +02:00
commit 0706ed4d35
3 changed files with 82 additions and 1 deletions

48
Lib/c/std_set.i Normal file
View file

@ -0,0 +1,48 @@
/* -----------------------------------------------------------------------------
* std_set.i
*
* SWIG typesets for std::set
* ----------------------------------------------------------------------------- */
%include <std_common.i>
// ------------------------------------------------------------------------
// std::set
// ------------------------------------------------------------------------
%{
#include <set>
#include <stdexcept>
%}
namespace std {
template<class T> class set {
public:
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T key_type;
typedef T value_type;
typedef value_type* pointer;
typedef const value_type* const_pointer;
typedef value_type& reference;
typedef const value_type& const_reference;
set();
set(const set& other);
size_t size() const;
bool empty() const;
void clear();
%extend {
bool add(const T& item) {
return self->insert(item).second;
}
bool del(const T& item) {
return self->erase(item) != 0;
}
bool has(const T& item) {
return self->count(item) != 0;
}
}
};
}