aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/SplitVector.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/SplitVector.h')
-rw-r--r--src/SplitVector.h33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/SplitVector.h b/src/SplitVector.h
index dc63b4ab6..2b4aed4be 100644
--- a/src/SplitVector.h
+++ b/src/SplitVector.h
@@ -26,20 +26,25 @@ protected:
/// hence be fast.
void GapTo(ptrdiff_t position) noexcept {
if (position != part1Length) {
- if (position < part1Length) {
- // Moving the gap towards start so moving elements towards end
- std::move_backward(
- body.data() + position,
- body.data() + part1Length,
- body.data() + gapLength + part1Length);
- } else { // position > part1Length
- // Moving the gap towards end so moving elements towards start
- std::move(
- body.data() + part1Length + gapLength,
- body.data() + gapLength + position,
- body.data() + part1Length);
+ try {
+ // This can never fail but std::move and std::move_backward are not noexcept.
+ if (position < part1Length) {
+ // Moving the gap towards start so moving elements towards end
+ std::move_backward(
+ body.data() + position,
+ body.data() + part1Length,
+ body.data() + gapLength + part1Length);
+ } else { // position > part1Length
+ // Moving the gap towards end so moving elements towards start
+ std::move(
+ body.data() + part1Length + gapLength,
+ body.data() + gapLength + position,
+ body.data() + part1Length);
+ }
+ part1Length = position;
+ } catch (...) {
+ // Ignore any exception
}
- part1Length = position;
}
}
@@ -280,7 +285,7 @@ public:
}
/// Retrieve a range of elements into an array
- void GetRange(T *buffer, ptrdiff_t position, ptrdiff_t retrieveLength) const noexcept {
+ void GetRange(T *buffer, ptrdiff_t position, ptrdiff_t retrieveLength) const {
// Split into up to 2 ranges, before and after the split then use memcpy on each.
ptrdiff_t range1Length = 0;
if (position < part1Length) {