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

Make as much of the interface as posible constexpr #132

Open
akrzemi1 opened this issue Sep 12, 2024 · 3 comments
Open

Make as much of the interface as posible constexpr #132

akrzemi1 opened this issue Sep 12, 2024 · 3 comments

Comments

@akrzemi1
Copy link
Member

Make as many functions as possible in the interface of optional constexpr. It is not possible to be as constexpr as std::opitonal, because the latter is C++17, where constexpr is mor powerful, whereas boost::optional needs to be C++11-compatible.

This requires changing the implementation of optional storage to a union-based.

@akrzemi1
Copy link
Member Author

For a union-based storage, see this implementation of Optional: https://github.com/akrzemi1/Optional

@typenameTea
Copy link
Contributor

Hello, I'll take a look into implementing this 🙂

@akrzemi1
Copy link
Member Author

As indicated in https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3527.html#rationale.constexpr the constexprification can only work fro Ts that are literal types, and still, you cannot do it for the copy and move constructors in C++11. But you can constexprify them in later C++ verisons.

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

No branches or pull requests

2 participants