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

Optimize cxx::optional for references or create a cxx::optional_ref #241

Open
elBoberido opened this issue Aug 13, 2020 · 0 comments
Open
Assignees
Labels
feature request Feature request under evaluation globex
Milestone

Comments

@elBoberido
Copy link
Member

elBoberido commented Aug 13, 2020

Brief feature description

The memory consumption of cxx::optional with nullable types can be reduced by removing the m_hasValue flag and inferring that information from the stored pointer.

Detailed information

A cxx::optional<T*> or cxx::optional<T&> doesn't need the m_hasValue flag, but can infer the information from the value being a nullptr.
It would be similar to a std::reference_wrapper, but with the advantage of being nullable so that instead of returning a raw pointer, a optional of a raw pointer or reference can be used. The benefit would be that when the optinoal contains a value, it would never be a nullptr and a developer can tell from the signature that the function might have a nulltopt.

Further information to consider when implementing:

@elBoberido elBoberido changed the title Optimize cxx::optional for references Optimize cxx::optional for references or create a cxx::optional_ref Sep 15, 2020
@elBoberido elBoberido reopened this Sep 15, 2020
@mossmaurice mossmaurice added the feature request Feature request under evaluation label Nov 2, 2020
@dkroenke dkroenke added the globex label Jun 8, 2022
@elBoberido elBoberido added this to the Low prio milestone Jun 9, 2022
@github-project-automation github-project-automation bot moved this to To do in v4.0 Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request under evaluation globex
Projects
Status: To do
Development

No branches or pull requests

3 participants