#include "pybind11_tests.h" // The main purpose of this test is to ensure the suggested BOILERPLATE code block below is // correct. // Copy this block of code into your project. // Replace FOOEXT with the name of your project. // BOILERPLATE BEGIN #ifdef FOOEXT_USING_PYBIND11_SMART_HOLDER # include #else # include PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE) template using classh = class_; PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE) # ifndef PYBIND11_SMART_HOLDER_TYPE_CASTERS # define PYBIND11_SMART_HOLDER_TYPE_CASTERS(...) # endif # ifndef PYBIND11_TYPE_CASTER_BASE_HOLDER # define PYBIND11_TYPE_CASTER_BASE_HOLDER(...) # endif #endif // BOILERPLATE END namespace { struct Foo0 {}; struct Foo1 {}; struct Foo2 {}; } // namespace PYBIND11_TYPE_CASTER_BASE_HOLDER(Foo1, std::shared_ptr) PYBIND11_SMART_HOLDER_TYPE_CASTERS(Foo2) TEST_SUBMODULE(classh_mock, m) { // Uses std::unique_ptr as holder in conservative mode, py::smart_holder in progressive // mode (if available). py::class_(m, "Foo0").def(py::init<>()); // Always uses std::shared_ptr as holder. py::class_>(m, "Foo1").def(py::init<>()); // Uses py::smart_holder if available, or std::unique_ptr if only pybind11 classic is // available. py::classh(m, "Foo2").def(py::init<>()); }