Skip to content

Undocumented required default constructor for types with type casters #1036

@ezyang

Description

@ezyang

Issue description

When defining a custom type caster as per http://pybind11.readthedocs.io/en/master/advanced/cast/custom.html it is required that the type you are casting to/from has a default constructor. Upon careful consideration of the sample code, it is not surprising that this is the case, but it is not documented, and it gives a rather opaque template expansion error:

call to implicitly-deleted default constructor of 'value_conv'

Reproducible example code

Do the same example as in the docs, but delete the default constructor.

struct inty { long long_value; inty(long v) : long_value(v) {} };

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