Enable static properties (py::metaclass) by default
Now that only one shared metaclass is ever allocated, it's extremely
cheap to enable it for all pybind11 types.
* Deprecate the default py::metaclass() since it's not needed anymore.
* Allow users to specify a custom metaclass via py::metaclass(handle).
diff --git a/docs/advanced/classes.rst b/docs/advanced/classes.rst
index e0463b4..232d13d 100644
--- a/docs/advanced/classes.rst
+++ b/docs/advanced/classes.rst
@@ -437,24 +437,15 @@
that are implemented in terms of C++ getters and setters.
Static properties can also be created in a similar way to expose getters and
-setters of static class attributes. Two things are important to note:
-
-1. Static properties are implemented by instrumenting the *metaclass* of the
- class in question -- however, this requires the class to have a modifiable
- metaclass in the first place. pybind11 provides a ``py::metaclass()``
- annotation that must be specified in the ``class_`` constructor, or any
- later method calls to ``def_{property_,∅}_{readwrite,readonly}_static`` will
- fail (see the example below).
-
-2. For static properties defined in terms of setter and getter functions, note
- that the implicit ``self`` argument also exists in this case and is used to
- pass the Python ``type`` subclass instance. This parameter will often not be
- needed by the C++ side, and the following example illustrates how to
- instantiate a lambda getter function that ignores it:
+setters of static class attributes. Note that the implicit ``self`` argument
+also exists in this case and is used to pass the Python ``type`` subclass
+instance. This parameter will often not be needed by the C++ side, and the
+following example illustrates how to instantiate a lambda getter function
+that ignores it:
.. code-block:: cpp
- py::class_<Foo>(m, "Foo", py::metaclass())
+ py::class_<Foo>(m, "Foo")
.def_property_readonly_static("foo", [](py::object /* self */) { return Foo(); });
Operator overloading