In our C++ program we have a template class that returns stuff, and depending on the stuff itself we return by value of by const reference.

This is done by using a tempalte class that contains typedefs to ReturnValue and such.

However, this seems to confuse SWIG immensely, as it then generates invalid C++ code, considering the said typedef to be a value type.

here is a minimalistic example of code that goes wrong (I have not checked, but this is pretty close to the problem I encounter)

//template class containing typedefs
template <typename TYPE>
    struct StoredType {
      // the type of the stored value
      typedef TYPE Value;
      // the type of the returned value
      typedef TYPE ReturnedValue;
      // the type of a returned const value
      typedef TYPE ReturnedConstValue;

//std::string specialization
 template <>                           
    struct StoredType<std::string> {                   
    typedef std::string *Value;                       
    typedef std::string& ReturnedValue;                   
    typedef const std::string& ReturnedConstValue;           

//template class that uses return values
class AbstractStuff {
ReturnedConstValue foo();

Does anyone have an idea of how I could hint SWIG that this typedef is in fact a reference ?
I have read through the documentation, and it seems typemaps are not what I want, and %rename cannot do this sort of wizardry.

Thanks a lot.

 - Always keep in mind that you may be wrong -