aboutsummaryrefslogtreecommitdiffstats
path: root/3rdparty/pybind11/docs/advanced/cast/stl.rst
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2022-09-14 09:28:47 +0200
committergatecat <gatecat@ds0.me>2022-09-14 09:28:47 +0200
commita72f898ff4c4237424c468044a6db9d6953b541e (patch)
tree1c4a543f661dd1b281aecf4660388491702fa8d8 /3rdparty/pybind11/docs/advanced/cast/stl.rst
parentf1349e114f3a16ccd002e8513339e18f5be4d31b (diff)
downloadnextpnr-a72f898ff4c4237424c468044a6db9d6953b541e.tar.gz
nextpnr-a72f898ff4c4237424c468044a6db9d6953b541e.tar.bz2
nextpnr-a72f898ff4c4237424c468044a6db9d6953b541e.zip
3rdparty: Bump vendored pybind11 version for py3.11 support
Signed-off-by: gatecat <gatecat@ds0.me>
Diffstat (limited to '3rdparty/pybind11/docs/advanced/cast/stl.rst')
-rw-r--r--3rdparty/pybind11/docs/advanced/cast/stl.rst19
1 files changed, 14 insertions, 5 deletions
diff --git a/3rdparty/pybind11/docs/advanced/cast/stl.rst b/3rdparty/pybind11/docs/advanced/cast/stl.rst
index 70fde0d2..03d49b29 100644
--- a/3rdparty/pybind11/docs/advanced/cast/stl.rst
+++ b/3rdparty/pybind11/docs/advanced/cast/stl.rst
@@ -42,7 +42,7 @@ types:
.. code-block:: cpp
// `boost::optional` as an example -- can be any `std::optional`-like container
- namespace pybind11 { namespace detail {
+ namespace PYBIND11_NAMESPACE { namespace detail {
template <typename T>
struct type_caster<boost::optional<T>> : optional_caster<boost::optional<T>> {};
}}
@@ -54,7 +54,7 @@ for custom variant types:
.. code-block:: cpp
// `boost::variant` as an example -- can be any `std::variant`-like container
- namespace pybind11 { namespace detail {
+ namespace PYBIND11_NAMESPACE { namespace detail {
template <typename... Ts>
struct type_caster<boost::variant<Ts...>> : variant_caster<boost::variant<Ts...>> {};
@@ -66,18 +66,27 @@ for custom variant types:
return boost::apply_visitor(args...);
}
};
- }} // namespace pybind11::detail
+ }} // namespace PYBIND11_NAMESPACE::detail
The ``visit_helper`` specialization is not required if your ``name::variant`` provides
a ``name::visit()`` function. For any other function name, the specialization must be
included to tell pybind11 how to visit the variant.
+.. warning::
+
+ When converting a ``variant`` type, pybind11 follows the same rules as when
+ determining which function overload to call (:ref:`overload_resolution`), and
+ so the same caveats hold. In particular, the order in which the ``variant``'s
+ alternatives are listed is important, since pybind11 will try conversions in
+ this order. This means that, for example, when converting ``variant<int, bool>``,
+ the ``bool`` variant will never be selected, as any Python ``bool`` is already
+ an ``int`` and is convertible to a C++ ``int``. Changing the order of alternatives
+ (and using ``variant<bool, int>``, in this example) provides a solution.
+
.. note::
pybind11 only supports the modern implementation of ``boost::variant``
which makes use of variadic templates. This requires Boost 1.56 or newer.
- Additionally, on Windows, MSVC 2017 is required because ``boost::variant``
- falls back to the old non-variadic implementation on MSVC 2015.
.. _opaque: