We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e87ee19 commit 5cad257Copy full SHA for 5cad257
docs/classes.rst
@@ -443,3 +443,14 @@ The entries defined by the enumeration type are exposed in the ``__members__`` p
443
...
444
445
By default, these are omitted to conserve space.
446
+
447
+In order to define additional methods on the enum class in Python, use `into_class()`
448
+method of the `enum_` object which will yield a `class_` instance:
449
450
+.. code-block:: cpp
451
452
+ py::enum_<Pet::Kind>(pet, "Kind")
453
+ .value("Dog", Pet::Kind::Dog)
454
+ .value("Cat", Pet::Kind::Cat)
455
+ .into_class()
456
+ .def("is_cat", [](const Pet::Kind& kind) { return kind == Pet::Kind::Cat; });
0 commit comments