mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-25 22:52:01 +00:00
parent
5b4751af26
commit
f6c4c1047a
@ -1484,6 +1484,8 @@ struct enum_base {
|
|||||||
PYBIND11_ENUM_OP_CONV("__ror__", a | b);
|
PYBIND11_ENUM_OP_CONV("__ror__", a | b);
|
||||||
PYBIND11_ENUM_OP_CONV("__xor__", a ^ b);
|
PYBIND11_ENUM_OP_CONV("__xor__", a ^ b);
|
||||||
PYBIND11_ENUM_OP_CONV("__rxor__", 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 {
|
} else {
|
||||||
PYBIND11_ENUM_OP_STRICT("__eq__", int_(a).equal(int_(b)), return false);
|
PYBIND11_ENUM_OP_STRICT("__eq__", int_(a).equal(int_(b)), return false);
|
||||||
|
@ -140,6 +140,7 @@ def test_binary_operators():
|
|||||||
assert int(m.Flags.Read | m.Flags.Execute) == 5
|
assert int(m.Flags.Read | m.Flags.Execute) == 5
|
||||||
assert int(m.Flags.Write | m.Flags.Execute) == 3
|
assert int(m.Flags.Write | m.Flags.Execute) == 3
|
||||||
assert int(m.Flags.Write | 1) == 3
|
assert int(m.Flags.Write | 1) == 3
|
||||||
|
assert ~m.Flags.Write == -3
|
||||||
|
|
||||||
state = m.Flags.Read | m.Flags.Write
|
state = m.Flags.Read | m.Flags.Write
|
||||||
assert (state & m.Flags.Read) != 0
|
assert (state & m.Flags.Read) != 0
|
||||||
|
Loading…
Reference in New Issue
Block a user