diff --git a/documentation/limitations.rst b/documentation/limitations.rst index 3b7d0401..b14cd956 100644 --- a/documentation/limitations.rst +++ b/documentation/limitations.rst @@ -74,6 +74,4 @@ The following operators will be ignored by binder: Miscellaneous ------------- -1. The pre/post increment operators both map to ``plus_plus``, with the pre-increment operator being invoked via ``a.plus_plus()`` and post-increment via ``.plus_plus(0)``; just as the operators are technically defined in C++. The same is true for the pre/post decrement operators, both called ``minus_minus``. - -2. User defined literals ``operator"" _foo`` end up being named as ``operator_foo``. +1. User defined literals ``operator"" _foo`` end up being named as ``operator_foo``. diff --git a/source/function.cpp b/source/function.cpp index 430e6bf3..26690414 100644 --- a/source/function.cpp +++ b/source/function.cpp @@ -73,8 +73,8 @@ string cpp_python_operator(const FunctionDecl & F) { {"operator!=", {"__ne__"}}, // {"operator[]", {"__getitem__"}}, // {"operator=", {"assign"}}, // - {"operator++", {"plus_plus"}}, // - {"operator--", {"minus_minus"}}, // + {"operator++", {"pre_increment", "post_increment"}}, // + {"operator--", {"pre_decrement", "post_decrement"}}, // {"operator->", {"arrow"}} // }; diff --git a/test/T12.operator.hpp b/test/T12.operator.hpp index 235d9e1c..601853c6 100644 --- a/test/T12.operator.hpp +++ b/test/T12.operator.hpp @@ -51,4 +51,6 @@ struct T T &operator=(const T &) { return *this; } T &operator++() { return *this; } T &operator--() { return *this; } + T &operator++(int) { return *this; } + T &operator--(int) { return *this; } }; diff --git a/test/T12.operator.ref b/test/T12.operator.ref index 807d9571..2a5e112c 100644 --- a/test/T12.operator.ref +++ b/test/T12.operator.ref @@ -47,8 +47,10 @@ void bind_T12_operator(std::function< pybind11::module &(std::string const &name cl.def("__ne__", (bool (T::*)(const struct T &)) &T::operator!=, "C++: T::operator!=(const struct T &) --> bool", pybind11::arg("")); cl.def("__getitem__", (bool (T::*)(int)) &T::operator[], "C++: T::operator[](int) --> bool", pybind11::arg("")); cl.def("assign", (struct T & (T::*)(const struct T &)) &T::operator=, "C++: T::operator=(const struct T &) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg("")); - cl.def("plus_plus", (struct T & (T::*)()) &T::operator++, "C++: T::operator++() --> struct T &", pybind11::return_value_policy::automatic); - cl.def("minus_minus", (struct T & (T::*)()) &T::operator--, "C++: T::operator--() --> struct T &", pybind11::return_value_policy::automatic); + cl.def("pre_increment", (struct T & (T::*)()) &T::operator++, "C++: T::operator++() --> struct T &", pybind11::return_value_policy::automatic); + cl.def("pre_decrement", (struct T & (T::*)()) &T::operator--, "C++: T::operator--() --> struct T &", pybind11::return_value_policy::automatic); + cl.def("post_increment", (struct T & (T::*)(int)) &T::operator++, "C++: T::operator++(int) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg("")); + cl.def("post_decrement", (struct T & (T::*)(int)) &T::operator--, "C++: T::operator--(int) --> struct T &", pybind11::return_value_policy::automatic, pybind11::arg("")); } }