From 286180ee0cc43e251442ca257c64430e269c0132 Mon Sep 17 00:00:00 2001 From: Henrique Gemignani Passos Lima Date: Tue, 22 Nov 2022 00:54:14 +0200 Subject: [PATCH] Fix compilation of CScriptSpecialFunction --- include/rstl/pointer_iterator.hpp | 5 +++++ include/rstl/vector.hpp | 14 +++++++++----- .../ScriptObjects/CScriptSpecialFunction.cpp | 1 + 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/rstl/pointer_iterator.hpp b/include/rstl/pointer_iterator.hpp index cd153e61..6ac59e77 100644 --- a/include/rstl/pointer_iterator.hpp +++ b/include/rstl/pointer_iterator.hpp @@ -120,6 +120,11 @@ struct const_counting_iterator { int count; const_counting_iterator(const T* ptr, int count) : ptr(ptr), count(count) {} + + const_counting_iterator& operator++() { + ++this->count; + return *this; + } }; template < typename It > diff --git a/include/rstl/vector.hpp b/include/rstl/vector.hpp index 5b90b535..d484166f 100644 --- a/include/rstl/vector.hpp +++ b/include/rstl/vector.hpp @@ -137,8 +137,11 @@ void vector< T, Alloc >::reserve(int newSize) { template < typename T, typename Alloc > typename vector< T, Alloc >::iterator vector< T, Alloc >::insert(iterator it, const T& value) { typename iterator::difference_type diff = it - begin(); // distance(begin(), it); - const_counting_iterator< T > in(&value, 0); - insert_into(it, 1, in); + + // // TODO: implement + // const_counting_iterator< T > in(&value, 0); + // insert_into(it, 1, in); + return begin() + diff; } @@ -165,15 +168,16 @@ typename vector< T, Alloc >::iterator vector< T, Alloc >::insert_into(iterator a } uninitialized_copy_n(in, n, begin() + diffFromAt); - + x4_count += n; } else { int newCapacity = x8_capacity != 0 ? x8_capacity * 2 : 4; - for (; newCapacity < newCount; newCapacity *= 2); + for (; newCapacity < newCount; newCapacity *= 2) + ; T* newData; x0_allocator.allocate(newData, newCapacity); - + int diffFromAt = at - begin(); uninitialized_copy_n(begin(), diffFromAt, newData); uninitialized_copy_n(in, n, newData + diffFromAt); diff --git a/src/MetroidPrime/ScriptObjects/CScriptSpecialFunction.cpp b/src/MetroidPrime/ScriptObjects/CScriptSpecialFunction.cpp index 1d21c725..90f822bc 100644 --- a/src/MetroidPrime/ScriptObjects/CScriptSpecialFunction.cpp +++ b/src/MetroidPrime/ScriptObjects/CScriptSpecialFunction.cpp @@ -30,6 +30,7 @@ #include "math.h" #include "rstl/math.hpp" +#include "rstl/iterator.hpp" namespace rstl { static int string_find(const string& haystack, const string& needle, int) {