Dear List,
If I try to create a STL-map with a pointer as a key, I get the following
compiler error:
error: `type_name' is not a member of `swig::traits<Key>' (with SWIG 1.3.34
and mingw 3.4.5, same effect in VC++ 8)
The following example code should reproduce the behaviour:
%include "std_map.i"
%module test
%{#include <map>
struct Value { double a,b; };
struct Key { int i; Key(int iIn=0) : i(iIn) {}};
%}
// A structure for the value
struct Value { double a,b; };
// A structure for the key pointer
struct Key { int i; Key(int iIn=0) : i(iIn) {}};
// Template for a map, produces illegal code
%template(pIntMap) std::map<Key*,Value>;
1.5 years ago (2006-12-17) Nitro gave for a similar case a workaround,
appending the following code to the .i file
%{
namespace swig {
template <> struct traits<Key> {
typedef pointer_category category;
static const char* type_name() { return"Key *"; }
};
}
%}
With this workaround the code compiles nicely, but I'm quite sure this is
not the intended behaviour of SWIG. Can it get fixed? Should I report it as
a bug? (Didn't found it in the buglist, but perhaps it is already there)
Another question:
I do not understand the workaround, does it have any side effects? In my
real application the key class is a very imported and of used abstract base
class.
Thank you for any help,
Philipp
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user