Is it possible to ensure that std::optional<T> arguments always have .none() ?
#82
-
|
with However, I believe that we still need to specify Is there a way we can simply allow |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
|
Yeah, it's something that slightly bothered me as well. I cannot think of an elegant way, which is why it probably wasn't part of the original PR #67. A hacky way to comes in mind would be to add some extra processing to For functions with explicit Ideally this processing could be done in a separate function to avoid making I would be open to a PR implementing this functionality but won't be able to do it myself. If anybody can think of something better, then that is also interesting. Ping @yosh-matsuda |
Beta Was this translation helpful? Give feedback.
Yeah, it's something that slightly bothered me as well. I cannot think of an elegant way, which is why it probably wasn't part of the original PR #67.
A hacky way to comes in mind would be to add some extra processing to
nb_func_new()(which is called whenever we bind a C++ function into the Python world).For functions with explicit
nb::argvalues, we would need to do a sweep overdescrand mark the associated entry asNone-compatible when encountering{Optional[in the string. For functions that don't havenb::argvalues, we would do the same thing but create unnamed arguments on the fly and attach them to the function.Ideally this processing could be done in a separate function to avo…