Search code examples
c#c++swigtypemaps

SWIG - No default typemap for std::list when wrapping to C#, how can I do?


I am currently working on wrapping a big C++ library to C# using SWIG. I am facing a big problem, since my library use a big amount of std::list, and it seems that SWIG (I am using the last release 3.0.12) doesn't supply a default mapping for std::list. I looked all over the web, nothing found.. I am quite surprised because std::list are quite similar to C# LinkedList !

Anyway, I am not in SWIG for a long time, so I don't really know how to do.. All I know is that I absolutely can't change all the std::list in my lib, and I'd really like to wrap them in C# LinkedList, but I don't know if it's possible and if I can do it easily..

I looked over typemaps, but I'm not sure it would worked correctly because mapping std::list to a LinkedList seems more complicated than using simple typemaps..

People, I need you to advise me ! Thanks in advance, Quentin.


Solution

  • Well, for those who are facing the same issue like I was, I finally decided to make my own implementation of std::list to C# LinkedList.

    I made a pull request on the SWIG GitHub today. If someone is interested, go check it. It is not perfect but work for now.