From 743ff09368f223c56beeda9b72b0520766130322 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 26 Dec 2018 19:54:52 -0500 Subject: [PATCH] [iter] Implement friend opeator + (int, iter) --- src/hb-iter.hh | 1 + src/test-iter.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index a353dec0c..bfa744a4d 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -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; } diff --git a/src/test-iter.cc b/src/test-iter.cc index 89ca79937..0e713e1f6 100644 --- a/src/test-iter.cc +++ b/src/test-iter.cc @@ -71,6 +71,7 @@ test_iterator (Iterator it) it += it.len () + 10; it = it + 10; + it = 10 + it; assert (*it == it[0]);