Skip to content

Provide warnning when overloading with builtin types #5

@edimetia3d

Description

@edimetia3d

Pybind11 intrinsically supports the binding of overloaded functions.

Nonetheless, several predicaments may arise:

  1. Pybind11 internally scrutinizes overloaded functions sequentially, employing the first viable function. Please refer to this Documentation for further details.
  2. Certain discrepancies exist between Python and C++ types, such as Python's bool being a subclass of int.

Consequently, when generating an overload solely reliant on the builtin type, potential complications could emerge. For instance:

Should you bind void Foo(int, float) prior to void Foo(bool, float), the Python call mod.foo(False, 8) would align with void Foo(int, float), a situation incongruous with the C++ overloading mechanism.

In the face of such circumstances, it would be prudent to issue appropriate warnings when generating binding code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions