Skip to content

Commit

Permalink
Use alignas instead of std::aligned_storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Kramer committed Aug 12, 2024
1 parent d1fcec8 commit a6c6c39
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion include/cereal/types/memory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,10 @@ namespace cereal
{
// Storage type for the pointer - since we can't default construct this type,
// we'll allocate it using std::aligned_storage and use a custom deleter
using AlignedStorage = typename std::aligned_storage<sizeof(T), CEREAL_ALIGNOF(T)>::type;
class alignas(T) AlignedStorage {
private:
std::byte data[sizeof(T)];
};

// Valid flag - set to true once construction finishes
// This prevents us from calling the destructor on
Expand Down

0 comments on commit a6c6c39

Please sign in to comment.