BAN: Cleanup Optional casting for value getters

This commit is contained in:
2024-10-06 18:22:06 +03:00
parent 4f7828bab9
commit f432d3fcf8

View File

@@ -167,14 +167,14 @@ namespace BAN
constexpr T& Optional<T>::value()
{
ASSERT(has_value());
return (T&)m_storage;
return *reinterpret_cast<T*>(&m_storage);
}
template<typename T>
constexpr const T& Optional<T>::value() const
{
ASSERT(has_value());
return (const T&)m_storage;
return *reinterpret_cast<const T*>(&m_storage);
}
template<typename T>
@@ -182,7 +182,7 @@ namespace BAN
{
if (!has_value())
return empty;
return (T&)m_storage;
return value();
}
template<typename T>
@@ -190,7 +190,7 @@ namespace BAN
{
if (!has_value())
return empty;
return (const T&)m_storage;
return value();
}
template<typename T>