[iter] Check for more before forwarding/rewinding past ends
This commit is contained in:
parent
c1c122e7b3
commit
606841b070
@ -196,11 +196,11 @@ struct hb_iter_fallback_mixin_t
|
|||||||
|
|
||||||
/* Advancing: Implement __next__(), or __forward__() if random-access. */
|
/* Advancing: Implement __next__(), or __forward__() if random-access. */
|
||||||
void __next__ () { *thiz() += 1; }
|
void __next__ () { *thiz() += 1; }
|
||||||
void __forward__ (unsigned n) { while (n--) ++*thiz(); }
|
void __forward__ (unsigned n) { while (*thiz() && n--) ++*thiz(); }
|
||||||
|
|
||||||
/* Rewinding: Implement __prev__() or __rewind__() if bidirectional. */
|
/* Rewinding: Implement __prev__() or __rewind__() if bidirectional. */
|
||||||
void __prev__ () { *thiz() -= 1; }
|
void __prev__ () { *thiz() -= 1; }
|
||||||
void __rewind__ (unsigned n) { while (n--) --*thiz(); }
|
void __rewind__ (unsigned n) { while (*thiz() && n--) --*thiz(); }
|
||||||
|
|
||||||
/* Range-based for: Implement __end__() if can be done faster,
|
/* Range-based for: Implement __end__() if can be done faster,
|
||||||
* and operator!=. */
|
* and operator!=. */
|
||||||
|
@ -82,10 +82,8 @@ test_iterator_non_default_constructable (Iter it)
|
|||||||
(void) _;
|
(void) _;
|
||||||
|
|
||||||
it += it.len ();
|
it += it.len ();
|
||||||
if (0)
|
it = it + 10;
|
||||||
it = it + 10;
|
it = 10 + it;
|
||||||
if (0)
|
|
||||||
it = 10 + it;
|
|
||||||
|
|
||||||
assert (*it == it[0]);
|
assert (*it == it[0]);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user