Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please add support for std::optional #3293

Closed
eyjohn opened this issue Dec 30, 2019 · 4 comments
Closed

Please add support for std::optional #3293

eyjohn opened this issue Dec 30, 2019 · 4 comments

Comments

@eyjohn
Copy link
Contributor

eyjohn commented Dec 30, 2019

I appreciate that there is already an issue for c++17 (#2206), but I was hoping that reducing the scope to a specific component of it: std::optional would make it easier to add earlier.

This would of course mean that it will not be fully supported, e.g. no emplace until things like variadic template parameters are implemented. However I think most of the useful functionality here: https://en.cppreference.com/w/cpp/utility/optional can already be supported.

@jjerphan
Copy link
Contributor

jjerphan commented Oct 1, 2021

@eyjohn: FYI, #4225 introduced some support for std::optional.

@da-woods
Copy link
Contributor

da-woods commented Oct 2, 2021

FYI, #4225 introduced some support for std::optional.

#4225 is not quite the same: it's using std::optional internally to try to make C++ objects behave more like Python objects (so that they're only initialized at their first use, that kind of thing). It probably ends up providing a lot of the functionality that people would try to use std::optional for, but you should view it as a feature that happens to be implemented with std::optional rather than a way of exposing std::optional.

So PRs remain welcome for a .pxd wrapper for std::optional - the basics should probably be fairly straight-forward to write.

@scoder scoder closed this as completed in 144546e Dec 17, 2021
@scoder scoder added this to the 3.0 milestone Dec 17, 2021
@isVoid
Copy link

isVoid commented Aug 22, 2022

Thank you very much for making this feature available! Is it possible to backport this to 0.29?

@da-woods
Copy link
Contributor

Is it possible to backport this to 0.29?

No. We really aren't backporting new features to 0.29.

However, the pxd files for the C++ standard library don't do anything special. You can just download https://github.com/cython/cython/blob/master/Cython/Includes/libcpp/optional.pxd and use it in your project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants