You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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:
The text was updated successfully, but these errors were encountered: