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

View file

@ -0,0 +1,33 @@
#include "li_std_set/li_std_set_wrap.h"
#include <assert.h>
int main() {
{
IntSet* is = IntSet_new();
IntSet_add(is, 1);
IntSet_add(is, 4);
IntSet_add(is, 9);
assert( IntSet_size(is) == 3 );
assert( IntSet_has(is, 4) );
assert( !IntSet_has(is, 16) );
IntSet_delete(is);
}
{
StringSet* ss = StringSet_new();
StringSet_add(ss, "foo");
StringSet_add(ss, "bar");
assert( StringSet_size(ss) == 2 );
assert( StringSet_has(ss, "bar") );
assert( !StringSet_has(ss, "baz") );
StringSet_delete(ss);
}
return 0;
}

View file

@ -22,7 +22,7 @@
%template(set_int) std::multiset<int>;
%template(v_int) std::vector<int>;
%template(set_string) std::set<std::string>;
#elif defined(SWIGJAVA) || defined(SWIGCSHARP)
#elif defined(SWIGC) || defined(SWIGJAVA) || defined(SWIGCSHARP)
// This operator is only defined because it's needed to store objects of
// type Foo in std::set in C++, we don't need to wrap it.
%ignore operator<;