-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide typemaps for boost or std::optional<T> #1307
Comments
There are no standard typemaps for this in SWIG but I do have my own typemaps for |
It would be great if you can share the snippet as I am also looking for the same. I am new to the SWIG and type mapping complex type is something I don’t understand as of now. |
@vadz, yes! They ought to port to |
@vadz yes can you guide me in the right track. |
@vadz Is the |
No, sorry, other higher priority tasks took over and I was never able to work on this. I've created some gists showing the typemaps we're using:
These typemaps are for a very simple custom |
Thanks a lot @vadz, your files have been very helpful. I am currently using a very simple swig configuration for
In your example I have't understood the logic behind I tried to make something more complex, similar to a templated typemap in order to have a more idiomatic usage from python, but I couldn't make it work. For instance, I would like to directly map optional numeric types and strings to the target language. In python: # Using the C++ signature
# std::optional<int> constructAndReturnOptional(const std::optional<int>&)
myint = mymodule.constructAndReturnOptional(42)
type(myint) # <class 'int'>
myint = mymodule.constructAndReturnOptional()
type(myint) # <class 'NoneType'> I am pretty sure that it can be done using templated Does anyone have any example? I tried to understand how is done for |
In C# the representation of C++
No, the macros contain it. For idiomatic usage, you really shouldn't be using |
I'm not really familiar with C#, but I think I got your point.
I updated my comment above to reflect what I really meant. Now it should be more clear. |
Hey @vadz , Sorry for a noob question. I'm looking at your java version. What exactly is OptionalValue in there. I get a Template 'OptionalValue' is undefined error. I just replaced it with optional and std::optional and get the same error, just with optional. EDIT: That's your custom optional class nm. |
|
+1 for feature request, for what it's worth. |
+1 for feature request. I am also very interested in seeing this implemented in SWIG. |
Hi ,
is there a way to typemap boost::optional to c# int? and vice versa
and also for other type like bool , string and other classes?
so far I only found this implementation.
https://stackoverflow.com/questions/15912937/can-you-swig-a-boostoptional
The text was updated successfully, but these errors were encountered: