summaryrefslogtreecommitdiff
path: root/include/fud_vector.hpp
diff options
context:
space:
mode:
authorDominick Allen <djallen@librehumanitas.org>2025-01-02 15:11:51 -0600
committerDominick Allen <djallen@librehumanitas.org>2025-01-02 15:11:51 -0600
commit87071200872c2450c947047350132aee493033c1 (patch)
tree49109532d9bbd148b4e59043120037684093be33 /include/fud_vector.hpp
parent16379362c02a2472f00fac49cad62788547c9519 (diff)
Get basic CSV parser operating.
Diffstat (limited to 'include/fud_vector.hpp')
-rw-r--r--include/fud_vector.hpp35
1 files changed, 33 insertions, 2 deletions
diff --git a/include/fud_vector.hpp b/include/fud_vector.hpp
index 9159770..1730c50 100644
--- a/include/fud_vector.hpp
+++ b/include/fud_vector.hpp
@@ -59,16 +59,21 @@ class Vector {
Vector& operator=(Vector<T>&& rhs) noexcept
{
- cleanup();
+ if (&rhs == this) {
+ return *this;
+ }
+ static_cast<void>(cleanup());
m_allocator = rhs.m_allocator;
m_data = rhs.m_data;
m_length = rhs.m_length;
m_capacity = rhs.m_length;
- rhs.m_allocataor = nullptr;
+ rhs.m_allocator = nullptr;
rhs.m_data = nullptr;
rhs.m_length = 0;
rhs.m_capacity = 0;
+
+ return *this;
}
static constexpr Vector<T> NullVector() noexcept {
@@ -629,6 +634,32 @@ class Vector {
return FudStatus::Success;
}
+ template <size_t Size>
+ FudStatus extend(Span<const T, Size> fixedSpan)
+ {
+ if (fixedSpan.data() == nullptr) {
+ return FudStatus::NullPointer;
+ }
+ if (std::numeric_limits<size_t>::max() - Size < m_length) {
+ return FudStatus::Failure;
+ }
+ if (m_length + Size > m_capacity)
+ {
+ auto status = grow();
+ if (status != FudStatus::Success) {
+ return status;
+ }
+ }
+
+ for (size_t spanIndex = 0; spanIndex < Size; ++spanIndex) {
+ const auto* ptr = new (m_data + m_length) T(fixedSpan[spanIndex]);
+ fudAssert(ptr != nullptr);
+ m_length++;
+ }
+
+ return FudStatus::Success;
+ }
+
FudStatus erase(size_t index)
{
if (index >= m_length) {