From ab26259c87152f676f66d2ae0e3ae7bcafa47fe2 Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Wed, 22 Mar 2017 21:39:19 +0100 Subject: [PATCH] added note about trailing commas (fixes #593) --- docs/advanced/classes.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/advanced/classes.rst b/docs/advanced/classes.rst index 232d13d59..8896441b6 100644 --- a/docs/advanced/classes.rst +++ b/docs/advanced/classes.rst @@ -230,6 +230,13 @@ override the ``name()`` method): std::string bark() override { PYBIND11_OVERLOAD(std::string, Dog, bark, ); } }; +.. note:: + + Note the trailing commas in the ``PYBIND11_OVERLOAD`` calls to ``name()`` + and ``bark()``. These are needed to portably implement a trampoline for a + function that does not take any arguments. For functions that take + a nonzero number of arguments, the trailing comma must be omitted. + A registered class derived from a pybind11-registered class with virtual methods requires a similar trampoline class, *even if* it doesn't explicitly declare or override any virtual methods itself: