Replies: 2 comments 1 reply
-
Changing to |
Beta Was this translation helpful? Give feedback.
-
Bump? It's been 3 years. Pointers in C can be null. Seems rather a basic aspect to support. Not to mention Relevant issue: #3175 |
Beta Was this translation helpful? Give feedback.
-
I have a function that does some conversion of its input arguments:
The current version works™, but as an empty array is a valid return value from
::internal_foo
I'd like to returnbytes
on success, butNone
on failure. AFAIC I could usestd::optional<py::bytes>
, but this would require at least C++14 (if usingstd::experimental::optional<>
), which I'd like to avoid.As far as I understand it right now, I could do this by changing the return type to
py::object
, but this would change the generated docstring to indicate the return type asany
(???), which is not what I intent for it. On the other hand, if I leave the realms of C++11, I could mark the return value asstd::optional<py::bytes>
, which should (in theory???) indicate the return value correctly to bepy::bytes
orNone
.Is there some way to both properly indicate this
py::bytes
vs.None
return value (in the docstring), allowing for empty py::bytes (zero-sized) being returned, and still have a sane/descriptive C++11 return type?NB:
py::bytes
is intentional as the internal function operates on binary data blobs.Beta Was this translation helpful? Give feedback.
All reactions