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 there, I have a C++ enum class and a method that takes values of this enum class as input, so I can enforce a constraint on the values I pass (vs. just passing a string). I mimicked the code here in the pybind tests.
If I expose my method with a standard def and the enum class this way:
then invoke from python, with something like this (suppose my module/C++ file is called pyenum and other_arg is a string):
method_using_enum(Enum.EntryOne, "")
I run into an error since we can't seem to resolve Enum.EntryOne from Python to the original enum value Enum::EntryOne in C++. Does anyone have thoughts about whether this is something on my end, or is there no support for enum-typed arguments to functions exposed through pybind?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi there, I have a C++ enum class and a method that takes values of this enum class as input, so I can enforce a constraint on the values I pass (vs. just passing a string). I mimicked the code here in the pybind tests.
If I expose my method with a standard
def
and the enum class this way:then invoke from python, with something like this (suppose my module/C++ file is called
pyenum
andother_arg
is a string):I run into an error since we can't seem to resolve
Enum.EntryOne
from Python to the original enum valueEnum::EntryOne
in C++. Does anyone have thoughts about whether this is something on my end, or is there no support for enum-typed arguments to functions exposed through pybind?Beta Was this translation helpful? Give feedback.
All reactions