提交 743ff093 编写于 作者: B Behdad Esfahbod

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

上级 6dc4a1c9
......@@ -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; }
......
......@@ -71,6 +71,7 @@ test_iterator (Iterator it)
it += it.len () + 10;
it = it + 10;
it = 10 + it;
assert (*it == it[0]);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册