Skip to content

Separate optional and variant support from other STL containers #1207

@funchal

Description

@funchal

I'd like to propose that we:

  • move std::optional and std::variant conversion support, which are currently in pybind11/stl.h, to a new file (say pybind11/utility.h since they are in the STL utility library in C++17).
  • include pybind11/utility.h from pybind11/stl.h so that we maintain full backward compatibility.
  • update the docs Overview page to mention the new header.

My motivation for this proposal is that the conversion for other containers (set/vector/map) in pybind11/stl.h comes with a major downside, documented in http://pybind11.readthedocs.io/en/stable/advanced/cast/stl.html#automatic-conversion, and I believe that optional/variant can be useful in their own right.

If you like the idea, I'm happy to prepare a pull request. Please let me know. #

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