diff --git a/icu4c/source/common/unicode/utf16cppiter.h b/icu4c/source/common/unicode/utf16cppiter.h index 777cea6174e4..bcb7221fd5b3 100644 --- a/icu4c/source/common/unicode/utf16cppiter.h +++ b/icu4c/source/common/unicode/utf16cppiter.h @@ -169,6 +169,15 @@ class U16IteratorBase { // @internal bool operator!=(const U16IteratorBase &other) const { return !operator==(other); } + // @internal + void dec() { + // TODO: assert current != limit -- more precisely: start <= current < limit + // Very similar to U16_BACK_1(). + if (U16_IS_TRAIL(*(--current)) && current != start && U16_IS_LEAD(*(current - 1))) { + --current; + } + } + // @internal CodeUnits readAndInc(const Unit16 *&p) const { // TODO: assert p != limit -- more precisely: start <= p < limit @@ -410,6 +419,14 @@ class U16UnsafeIteratorBase { // @internal bool operator!=(const U16UnsafeIteratorBase &other) const { return !operator==(other); } + // @internal + void dec() { + // Very similar to U16_BACK_1_UNSAFE(). + if (U16_IS_TRAIL(*(--current))) { + --current; + } + } + // @internal UnsafeCodeUnits readAndInc(const Unit16 *&p) const { // Very similar to U16_NEXT_UNSAFE().