[iter] Implement friend opeator + (int, iter)

This commit is contained in:
Behdad Esfahbod 2018-12-26 19:54:52 -05:00
parent 6dc4a1c9b1
commit 743ff09368
2 changed files with 2 additions and 0 deletions

View File

@ -67,6 +67,7 @@ struct hb_iter_t
iter_t& operator -= (unsigned count) { rewind (count); return *thiz(); }
iter_t& operator -- () { prev (); return *thiz(); }
iter_t operator + (unsigned count) const { iter_t c (*thiz()); c += count; return c; }
friend iter_t operator + (unsigned count, const iter_t &it) { return it + count; }
iter_t operator ++ (int) { iter_t c (*thiz()); ++*thiz(); return c; }
iter_t operator - (unsigned count) const { iter_t c (*thiz()); c -= count; return c; }
iter_t operator -- (int) { iter_t c (*thiz()); --*thiz(); return c; }

View File

@ -71,6 +71,7 @@ test_iterator (Iterator it)
it += it.len () + 10;
it = it + 10;
it = 10 + it;
assert (*it == it[0]);