-
Notifications
You must be signed in to change notification settings - Fork 700
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
Template specialization #24
Comments
Yep, given template specialization is not available for rust (at least for stable), we can't do better than that. Leaving this open so when it gets stabilized we aim to do something smarter. Until then there's not too much we can do that doing the generic one if found or the first instantiation if not :/ |
Oh, btw, thanks for filling this bugs, they're really useful :) |
Would it be possible to do the same as with function (appending something at the end of the class name) ? (Off-Topic but I don't know where to ask : once there is template specialization for rust, is it possible to use it for handling c++ overload... instead of generating multiple functions ?) |
Yes, it would but then in rust you have Regarding the C++ function overloads... yes, I guess so (though it has to be written :P). |
I was going to say that bindgen add a postfix to C++ template function, I checked to be sure and I saw that not specialized template function are not handled (same reason as template class I guess). For C++ function overload, it would make more sense to use template specialization (IMHO). Having one (rust) function by (C++) overload would weird (having X functions with some obviously computer-generated postfix is not the best), and would cause function bloat in some case. |
I'm not sure If template <typename T>
class test{};
template<>
class test<int> {
int foo;
};
template<>
class test<float> {
float foo;
}; becomes struct Test<T> {}
struct TestInt { foo: c_int }
struct TestFloat { foo: c_float } but I don't think this is a proper solution. |
Unless rust add generic specialisation, I also don't think there's a good solution. I think adding a warning when template specialisation is encountered in C++ code is required tho. Having code be silently ignored isn't good :). |
Hi,
bindgen ignore template specialization for class (and struct) and select the first "working answer".
For example :
give
The float specialization is ignored.
And with a valid
test<T>
:gives :
Both the float and int specialization are ignored.
The text was updated successfully, but these errors were encountered: