mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-13 09:03:54 +00:00
quench __setstate__ warnings (fixes #1522)
This commit is contained in:
parent
ef13fb2e1c
commit
c8e9f3ccad
@ -1503,9 +1503,11 @@ NAMESPACE_END(detail)
|
|||||||
/// Binds C++ enumerations and enumeration classes to Python
|
/// Binds C++ enumerations and enumeration classes to Python
|
||||||
template <typename Type> class enum_ : public class_<Type> {
|
template <typename Type> class enum_ : public class_<Type> {
|
||||||
public:
|
public:
|
||||||
using class_<Type>::def;
|
using Base = class_<Type>;
|
||||||
using class_<Type>::def_property_readonly;
|
using Base::def;
|
||||||
using class_<Type>::def_property_readonly_static;
|
using Base::attr;
|
||||||
|
using Base::def_property_readonly;
|
||||||
|
using Base::def_property_readonly_static;
|
||||||
using Scalar = typename std::underlying_type<Type>::type;
|
using Scalar = typename std::underlying_type<Type>::type;
|
||||||
|
|
||||||
template <typename... Extra>
|
template <typename... Extra>
|
||||||
@ -1520,7 +1522,10 @@ public:
|
|||||||
#if PY_MAJOR_VERSION < 3
|
#if PY_MAJOR_VERSION < 3
|
||||||
def("__long__", [](Type value) { return (Scalar) value; });
|
def("__long__", [](Type value) { return (Scalar) value; });
|
||||||
#endif
|
#endif
|
||||||
def("__setstate__", [](Type &value, Scalar arg) { value = static_cast<Type>(arg); });
|
cpp_function setstate(
|
||||||
|
[](Type &value, Scalar arg) { value = static_cast<Type>(arg); },
|
||||||
|
is_method(*this));
|
||||||
|
attr("__setstate__") = setstate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Export enumeration entries into the parent scope
|
/// Export enumeration entries into the parent scope
|
||||||
|
Loading…
Reference in New Issue
Block a user