[ox/std] Remove placement new from Array
This commit is contained in:
parent
0790d8e9c2
commit
ccfc7d5405
13
deps/ox/src/ox/std/array.hpp
vendored
13
deps/ox/src/ox/std/array.hpp
vendored
@ -138,8 +138,6 @@ class Array {
|
||||
public:
|
||||
constexpr Array() noexcept = default;
|
||||
|
||||
explicit constexpr Array(std::size_t size) noexcept;
|
||||
|
||||
constexpr Array(std::initializer_list<T> list) noexcept;
|
||||
|
||||
constexpr Array(const Array &other);
|
||||
@ -216,13 +214,6 @@ constexpr ArrayIt<T, ArraySize, RefType, reverse> operator+(std::size_t n, const
|
||||
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>
|
||||
constexpr Array<T, ArraySize>::Array(std::initializer_list<T> list) noexcept {
|
||||
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>
|
||||
constexpr Array<T, ArraySize>::Array(const Array &other) {
|
||||
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 {
|
||||
if (this != &other) {
|
||||
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]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user