diff --git a/tests/test_stl_binders.cpp b/tests/test_stl_binders.cpp index 6d1f76e95c6..e38ad3df96d 100644 --- a/tests/test_stl_binders.cpp +++ b/tests/test_stl_binders.cpp @@ -83,6 +83,32 @@ struct RecursiveMap : std::map { using Parent::Parent; }; +/* + * Pybind11 does not catch more complicated recursion schemes, such as mutual + * recursion. + * In that case, an alternative is to add a custom overload. + */ +struct MutuallyRecursiveMap; +struct MutuallyRecursiveVector; + +struct MutuallyRecursiveMap : std::map {}; +struct MutuallyRecursiveVector : std::vector {}; + +namespace pybind11 { +namespace detail { +template <> +struct is_comparable : std::true_type {}; +template <> +struct is_copy_assignable : std::true_type {}; +template <> +struct is_copy_assignable : std::true_type {}; +template <> +struct is_copy_constructible : std::true_type {}; +template <> +struct is_copy_constructible : std::true_type {}; +} // namespace detail +} // namespace pybind11 + TEST_SUBMODULE(stl_binders, m) { // test_vector_int py::bind_vector>(m, "VectorInt", py::buffer_protocol()); @@ -165,4 +191,6 @@ TEST_SUBMODULE(stl_binders, m) { py::bind_vector(m, "RecursiveVector"); py::bind_map(m, "RecursiveMap"); + py::bind_map(m, "MutuallyRecursiveMap"); + py::bind_vector(m, "MutuallyRecursiveVector"); }