Add a scope guard call policy
```c++
m.def("foo", foo, py::call_guard<T>());
```
is equivalent to:
```c++
m.def("foo", [](args...) {
T scope_guard;
return foo(args...); // forwarded arguments
});
```
diff --git a/docs/advanced/misc.rst b/docs/advanced/misc.rst
index d984665..6ebc0c3 100644
--- a/docs/advanced/misc.rst
+++ b/docs/advanced/misc.rst
@@ -15,6 +15,7 @@
the beginning of the next parameter. Use a ``typedef`` to bind the template to
another name and use it in the macro to avoid this problem.
+.. _gil:
Global Interpreter Lock (GIL)
=============================
@@ -68,6 +69,13 @@
return m.ptr();
}
+The ``call_go`` wrapper can also be simplified using the `call_guard` policy
+(see :ref:`call_policies`) which yields the same result:
+
+.. code-block:: cpp
+
+ m.def("call_go", &call_go, py::call_guard<py::gil_scoped_release>());
+
Binding sequence data types, iterators, the slicing protocol, etc.
==================================================================