Skip to content

Mutable C++ lvalue arguments for immutable or rvalue Python types #823

Open
@aldanor

Description

@aldanor

I was wondering whether pybind11 happily accepting this kind of functions could be misleading:

.def("f", [](int& x) { x = 42; })

One may assume that pushing back to a std::vector<>& would update the list (although a related example is in the docs). Basically, for non-opaque types that require type conversion, is it possible to disable passing them as non-const refs, or do we not have this info at compile time?

Metadata

Metadata

Assignees

No one assigned

    Labels

    castersRelated to casters, and to be taken into account when analyzing/reworking castersenhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions