Skip to content

smart_holder: open issues #2901

Closed
Closed
@rhaschke

Description

@rhaschke

When using @rwgk's smart_holder branch and providing a custom holder type like this:

py::class_<MyClass, std::shared_ptr<MyClass>, MyBaseClass>(m, "MyClass")
		.def(py::init<>());

I've got a misleading static assert:

pybind11/include/pybind11/pybind11.h:1297:13: error: static assertion failed: py::class_ holder vs type_caster mismatch: missing PYBIND11_SMART_POINTER_HOLDER_TYPE_CASTERS(T, std::shared_ptr<T>)?
 1297 |             !(detail::is_instantiation<std::shared_ptr, holder_type>::value
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1298 |               && wrapped_type_uses_smart_holder_type_caster),
      |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I would assume:

  1. That it is possible to define custom holders
  2. If multiple holder types are defined, a more informative assert would be thrown

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions