diff --git a/luna/include/luna/Option.h b/luna/include/luna/Option.h index bbe09698..ce5a57dd 100644 --- a/luna/include/luna/Option.h +++ b/luna/include/luna/Option.h @@ -138,26 +138,16 @@ template class Option private: struct Storage { - u8 buffer[sizeof(T)]; - - T* fetch_ptr() - { - return (T*)buffer; - } + alignas(T) u8 buffer[sizeof(T)]; T& fetch_reference() { - return *fetch_ptr(); - } - - const T* fetch_ptr() const - { - return (const T*)buffer; + return *__builtin_launder(reinterpret_cast(&buffer)); } const T& fetch_reference() const { - return *fetch_ptr(); + return *__builtin_launder(reinterpret_cast(&buffer)); } void store_reference(const T& ref)