Added write only property functions for issue #1142 (#1144)

py::class_<T>'s `def_property` and `def_property_static` can now take a
`nullptr` as the getter to allow a write-only property to be established
(mirroring Python's `property()` built-in when `None` is given for the
getter).

This also updates properties to use the new nullptr constructor internally.
This commit is contained in:
Ted Drain
2017-11-07 08:35:27 -08:00
committed by Jason Rhinelander
parent 71178922fd
commit 0a0758ce3a
5 changed files with 73 additions and 18 deletions

View File

@@ -155,6 +155,9 @@ the setter and getter functions:
.def_property("name", &Pet::getName, &Pet::setName)
// ... remainder ...
Write only properties can be defined by passing ``nullptr`` as the
input for the read function.
.. seealso::
Similar functions :func:`class_::def_readwrite_static`,