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

Missing cmake/swig macro to wrap template function members #433

Open
phcerdan opened this Issue Jan 22, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@phcerdan
Copy link
Contributor

phcerdan commented Jan 22, 2019

From: https://stackoverflow.com/questions/51254957/swigging-a-class-member-function-that-is-a-template-function

%module example
%{
#include<iostream>

class MyClass {
public:
    template <class T>
    void f1(const std::string& firstArg, const T& value) {
        std::cout << firstArg << ',' << value << '\n';
    }
};
%}

%include <std_string.i>

class MyClass {
public:
    template <class T>
    void f1(const std::string& firstArg, const T& value);
};

%extend MyClass {
    %template(f1) f1<std::string>;
    %template(f1) f1<int>;
}

But I don't think there is a mechanism in place to do this. I guess a CMake macro with the name of the class to extend, the name of the template function, and the template types to instantiate might do this possible. Pinging @glehmann for tips and suggestions! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment