[*] Fix remove range

This commit is contained in:
Reece Wilson 2022-12-18 19:05:42 +00:00
parent 122fc74a66
commit b16f8613d8

View File

@ -113,14 +113,13 @@ inline void AuRemoveRange(T &in, AuUInt index, AuUInt length)
}
auto begin = in.begin();
auto end = begin;
std::advance(begin, index);
std::advance(end, index + length);
while (begin != end)
for (AuUInt i = 0; i < length; i++)
{
in.erase(begin++);
begin = in.erase(begin);
if (begin == in.end()) break;
}
}
@ -135,14 +134,13 @@ inline bool AuTryRemoveRange(T &in, AuUInt index, AuUInt length)
}
auto begin = in.begin();
auto end = begin;
std::advance(begin, index);
std::advance(end, index + length);
while (begin != end)
for (AuUInt i = 0; i < length; i++)
{
in.erase(begin++);
begin = in.erase(begin);
if (begin == in.end()) return i == length - 1;
}
}
AUROXTL_COMMODITY_CATCH