From c8e9f3ccad8cde7bf5e1b33bf822ec7364e8ff0d Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Fri, 14 Sep 2018 12:07:47 +0200 Subject: [PATCH] quench __setstate__ warnings (fixes #1522) --- include/pybind11/pybind11.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 26a033473..84577e975 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1503,9 +1503,11 @@ NAMESPACE_END(detail) /// Binds C++ enumerations and enumeration classes to Python template class enum_ : public class_ { public: - using class_::def; - using class_::def_property_readonly; - using class_::def_property_readonly_static; + using Base = class_; + using Base::def; + using Base::attr; + using Base::def_property_readonly; + using Base::def_property_readonly_static; using Scalar = typename std::underlying_type::type; template @@ -1520,7 +1522,10 @@ public: #if PY_MAJOR_VERSION < 3 def("__long__", [](Type value) { return (Scalar) value; }); #endif - def("__setstate__", [](Type &value, Scalar arg) { value = static_cast(arg); }); + cpp_function setstate( + [](Type &value, Scalar arg) { value = static_cast(arg); }, + is_method(*this)); + attr("__setstate__") = setstate; } /// Export enumeration entries into the parent scope