Skip to content

Commit

Permalink
replace std::aligned_storage_t with std::array in object_t
Browse files Browse the repository at this point in the history
Since std::aligned_storage_t is being deprecated, replace it with `alignas(T) std::array<std::byte, sizeof(T)>`.
  • Loading branch information
wbenny committed Aug 1, 2019
1 parent 68db2ad commit 82b7070
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/hvpp/hvpp/lib/object.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once
#include <array>
#include <type_traits>
#include <cstdint>

//
// Object class to create type-erasure'd static objects.
Expand Down Expand Up @@ -53,8 +53,9 @@ class object_t
T& operator*() noexcept { return as_object(); }

private:
const T& as_object() const noexcept { return reinterpret_cast<T&>(object_data_); }
T& as_object() noexcept { return reinterpret_cast<T&>(object_data_); }
const T& as_object() const noexcept { return reinterpret_cast<T&>(*object_data_.data()); }
T& as_object() noexcept { return reinterpret_cast<T&>(*object_data_.data()); }

std::aligned_storage_t<sizeof(T), alignof(T)> object_data_;
alignas(T)
std::array<std::byte, sizeof(T)> object_data_;
};

0 comments on commit 82b7070

Please sign in to comment.