make arithmetic operators of enum_ optional (#508)
Following commit 90d278, the object code generated by the python
bindings of nanogui (github.com/wjakob/nanogui) went up by a whopping
12%. It turns out that that project has quite a few enums where we don't
really care about arithmetic operators.
This commit thus partially reverts the effects of #503 by introducing
an additional attribute py::arithmetic() that must be specified if the
arithmetic operators are desired.
diff --git a/docs/advanced/cast/overview.rst b/docs/advanced/cast/overview.rst
index e9f43be..8408572 100644
--- a/docs/advanced/cast/overview.rst
+++ b/docs/advanced/cast/overview.rst
@@ -77,7 +77,7 @@
+------------------------------------+---------------------------+-------------------------------+
| Data type | Description | Header file |
-+=---================================+===========================+===============================+
++====================================+===========================+===============================+
| ``int8_t``, ``uint8_t`` | 8-bit integers | :file:`pybind11/pybind11.h` |
+------------------------------------+---------------------------+-------------------------------+
| ``int16_t``, ``uint16_t`` | 16-bit integers | :file:`pybind11/pybind11.h` |
diff --git a/docs/classes.rst b/docs/classes.rst
index 300816d..3e8f2ee 100644
--- a/docs/classes.rst
+++ b/docs/classes.rst
@@ -393,4 +393,18 @@
1L
+.. note::
+
+ When the special tag ``py::arithmetic()`` is specified to the ``enum_``
+ constructor, pybind11 creates an enumeration that also supports rudimentary
+ arithmetic and bit-level operations like comparisons, and, or, xor, negation,
+ etc.
+
+ .. code-block:: cpp
+
+ py::enum_<Pet::Kind>(pet, "Kind", py::arithmetic())
+ ...
+
+ By default, these are omitted to conserve space.
+
.. [#f1] Stateless closures are those with an empty pair of brackets ``[]`` as the capture object.