You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use the pybind11 library with a very basic example. I am trying to apply pybind11 to a template class doing basic operations (for the example). I did research for a long time in order to know whether someone had faced a similar mistake but so far they are fruitless, that's why I decided to open this issue.
Here is the template class Operations (i don't include the cpp file as function are extremely simple)
And here is the file used to bind it to a python library
When I attempt to install it, I have the following error :
error: no matching function for call to ‘pybind11::class_<Operations >::def(std::__cxx11::basic_string, int (Operations::*)(int, int))’
26 | .def("subtract"+type, &operations::subtract);
Thank you for your time
PS : It is the first time I open an issue, I am sincerely sorry if I was not supposed to do it for this kind of error that I think is only because I did something wrong. Obviously, I looked into the faq.html of pybind11 and found nothing relevant for my case. I didn't add the CMakeLists.txt and the setup.py, I will, if you think the error might come from them.
The text was updated successfully, but these errors were encountered:
The issue seems to be that class_::def is expecting a const char * as first name argument, and you're giving it a std::string. As far as I can quickly check, I believe name is copied inside of the call to def, so ("add"+type).c_str() might work, but best be careful and check.
PS : It is the first time I open an issue, I am sincerely sorry if I was not supposed to do it for this kind of error that I think is only because I did something wrong. Obviously, I looked into the faq.html of pybind11 and found nothing relevant for my case. I didn't add the CMakeLists.txt and the setup.py, I will, if you think the error might come from them.
No worries; thanks for all the information and self-contained exampled. Since you're asking yourself, two small tips:
If you post code as text (between ```) instead of screenshots, it's a lot easier for other to investigate by copying your code.
For this kind of question, rather than an actual/potential issue with pybind11, there's Gitter
Hello,
I am trying to use the pybind11 library with a very basic example. I am trying to apply pybind11 to a template class doing basic operations (for the example). I did research for a long time in order to know whether someone had faced a similar mistake but so far they are fruitless, that's why I decided to open this issue.
Here is the template class Operations (i don't include the cpp file as function are extremely simple)

And here is the file used to bind it to a python library

When I attempt to install it, I have the following error :
error: no matching function for call to ‘pybind11::class_<Operations >::def(std::__cxx11::basic_string, int (Operations::*)(int, int))’
26 | .def("subtract"+type, &operations::subtract);
Thank you for your time
PS : It is the first time I open an issue, I am sincerely sorry if I was not supposed to do it for this kind of error that I think is only because I did something wrong. Obviously, I looked into the faq.html of pybind11 and found nothing relevant for my case. I didn't add the CMakeLists.txt and the setup.py, I will, if you think the error might come from them.
The text was updated successfully, but these errors were encountered: