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
Hi. I am just wondering have you tried creating one constructor with default arguments the same way as it is described in pybind11 documentations??
I tried to do that. I did not find a correct way that clang stuff may support for default value of the argument. So I did it in this way: https://github.com/RosettaCommons/binder/compare/master...yosoufe:defaultValueForDefaultArguments?expand=1
I have already seen some problem with it that it does not generalize. for example if the argument type is Enum, in the C++ code the Enum should be defined with its all namespaces until it will be compilable.
is compilable. But in my branch, I have to write it in the following way until the bindings are also compilable Astruct(double v1, enumType type = Astruct::enumType::T1); because I simply copy what is after the = into the binding codes.
Do you have any better idea??
And also any other problems that may occur that I cannot see it?
The text was updated successfully, but these errors were encountered:
Re using Pybind11 default: - making bindings default arguments that way will be evaluate using Python evaluation strategy (ie evaluate once during binding time) which will be error prone and quite confusing for any non constant defaults (consider for example default that is a function call - in C++ such function would be called each time function is called)
re need to fully qualify names for default parameters: i think that is unavoidable. The core issue here is that default value specified during class declaration and during binding code evaluate in different translation units and there is no general way to map one to the other (consider for example that besides using unqualified declaration from class inner namespace C++ code could also use unqualified default value from unrelated namespaces pulled-in with using detectives). So using lambdas and explicitly generating multiple overloads seems to be the only general solution to me.
Hi. I am just wondering have you tried creating one constructor with default arguments the same way as it is described in pybind11 documentations??
I tried to do that. I did not find a correct way that clang stuff may support for default value of the argument. So I did it in this way:
https://github.com/RosettaCommons/binder/compare/master...yosoufe:defaultValueForDefaultArguments?expand=1
I have already seen some problem with it that it does not generalize. for example if the argument type is Enum, in the C++ code the Enum should be defined with its all namespaces until it will be compilable.
For example:
is compilable. But in my branch, I have to write it in the following way until the bindings are also compilable
Astruct(double v1, enumType type = Astruct::enumType::T1);
because I simply copy what is after the=
into the binding codes.Do you have any better idea??
And also any other problems that may occur that I cannot see it?
The text was updated successfully, but these errors were encountered: