mirror of
https://github.com/esphome/esphome.git
synced 2026-10-07 03:16:37 +00:00
address bot comments
This commit is contained in:
@@ -2235,11 +2235,12 @@ template<class T> struct PlacementStorage {
|
||||
/// @brief Raw byte storage, strictly aligned for type T.
|
||||
alignas(T) unsigned char data[sizeof(T)];
|
||||
|
||||
/// @brief Retrieves a pointer to the constructed object.
|
||||
T *get() { return std::launder(reinterpret_cast<T *>(data)); }
|
||||
/// @brief Retrieves a pointer to the storage as the target type.
|
||||
/// The caller must ensure the object has been constructed via placement new before dereferencing.
|
||||
T *get() { return reinterpret_cast<T *>(data); }
|
||||
|
||||
/// @brief Retrieves a const pointer to the constructed object.
|
||||
const T *get() const { return std::launder(reinterpret_cast<const T *>(data)); }
|
||||
/// @brief Retrieves a const pointer to the storage as the target type.
|
||||
const T *get() const { return reinterpret_cast<const T *>(data); }
|
||||
};
|
||||
|
||||
/// @name Internal functions
|
||||
|
||||
Reference in New Issue
Block a user