[ox/std] Remove placement new from Array

This commit is contained in:
Gary Talent 2022-03-23 03:05:50 -05:00
parent 0790d8e9c2
commit ccfc7d5405

View File

@ -138,8 +138,6 @@ class Array {
public: public:
constexpr Array() noexcept = default; constexpr Array() noexcept = default;
explicit constexpr Array(std::size_t size) noexcept;
constexpr Array(std::initializer_list<T> list) noexcept; constexpr Array(std::initializer_list<T> list) noexcept;
constexpr Array(const Array &other); constexpr Array(const Array &other);
@ -216,13 +214,6 @@ constexpr ArrayIt<T, ArraySize, RefType, reverse> operator+(std::size_t n, const
return a + n; return a + n;
} }
template<typename T, std::size_t ArraySize>
constexpr Array<T, ArraySize>::Array(std::size_t size) noexcept {
for (std::size_t i = 0; i < size; ++i) {
m_items[i] = {};
}
}
template<typename T, std::size_t ArraySize> template<typename T, std::size_t ArraySize>
constexpr Array<T, ArraySize>::Array(std::initializer_list<T> list) noexcept { constexpr Array<T, ArraySize>::Array(std::initializer_list<T> list) noexcept {
for (auto i = 0ul; auto &item : list) { for (auto i = 0ul; auto &item : list) {
@ -234,7 +225,7 @@ constexpr Array<T, ArraySize>::Array(std::initializer_list<T> list) noexcept {
template<typename T, std::size_t ArraySize> template<typename T, std::size_t ArraySize>
constexpr Array<T, ArraySize>::Array(const Array &other) { constexpr Array<T, ArraySize>::Array(const Array &other) {
for (std::size_t i = 0; i < ArraySize; ++i) { for (std::size_t i = 0; i < ArraySize; ++i) {
new (&m_items[i]) T(other.m_items[i]); m_items[i] = T(other.m_items[i]);
} }
} }
@ -242,7 +233,7 @@ template<typename T, std::size_t ArraySize>
constexpr Array<T, ArraySize>::Array(Array &&other) noexcept { constexpr Array<T, ArraySize>::Array(Array &&other) noexcept {
if (this != &other) { if (this != &other) {
for (std::size_t i = 0; i < ArraySize; ++i) { for (std::size_t i = 0; i < ArraySize; ++i) {
new (&m_items[i]) T(std::move(other.m_items[i])); m_items[i] = T(std::move(other.m_items[i]));
} }
} }
} }