restores __invert__ to arithmetic-enabled enum, fixes #1907 (#1909)

diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h
index fbd971c..a7fe189 100644
--- a/include/pybind11/pybind11.h
+++ b/include/pybind11/pybind11.h
@@ -1484,6 +1484,8 @@
                 PYBIND11_ENUM_OP_CONV("__ror__",  a |  b);
                 PYBIND11_ENUM_OP_CONV("__xor__",  a ^  b);
                 PYBIND11_ENUM_OP_CONV("__rxor__", a ^  b);
+                m_base.attr("__invert__") = cpp_function(
+                    [](object arg) { return ~(int_(arg)); }, is_method(m_base));
             }
         } else {
             PYBIND11_ENUM_OP_STRICT("__eq__",  int_(a).equal(int_(b)), return false);
diff --git a/tests/test_enum.py b/tests/test_enum.py
index d0989ad..2f119a3 100644
--- a/tests/test_enum.py
+++ b/tests/test_enum.py
@@ -140,6 +140,7 @@
     assert int(m.Flags.Read | m.Flags.Execute) == 5
     assert int(m.Flags.Write | m.Flags.Execute) == 3
     assert int(m.Flags.Write | 1) == 3
+    assert ~m.Flags.Write == -3
 
     state = m.Flags.Read | m.Flags.Write
     assert (state & m.Flags.Read) != 0