[Swig-user] mapping of a specialised template class

1 view
Skip to first unread message

Serge Ratke

unread,
Mar 17, 2012, 1:37:46 PM3/17/12
to swig...@lists.sourceforge.net
hey guys,

i'm having a hard time figuring out how to make swig understand which function
to use:

// module.i

%include "stl.i"
%include "std_string.i"
%include "std_vector.i"

template<class T>
class GenericState : public State {
public:
GenericState( const string& );
GenericState( const string&, T );
~GenericState();
T value() const;
};

template<class T>
class GenericState<vector<T> > : public State {
public:
GenericState( const string& );
GenericState( const string&, vector<T> );
~GenericState();
T value( const s32 ) const;
};

%template(StateInt) GenericState<int>;
%template(StateString) GenericState<string>;
%template(StateIntVector) GenericState<vector<int> >;

// error message

Error: no matching function to call »GenericState<std::vector<int> >::value()
const«
candidate is: T GenericState<std::vector<_RealType> >::value(int) const [with
T = int, s32 = unsigned int]

the generated wraper code for StateIntVector calls the function value() where
value(const s32) should have been called.

cheers
Reply all
Reply to author
Forward
0 new messages