[iter] Add operator>> and operator<<

This commit is contained in:
Behdad Esfahbod 2019-01-28 16:23:12 -05:00
parent 8bd96be994
commit 57795bc8dd
2 changed files with 8 additions and 0 deletions

View File

@ -84,6 +84,10 @@ struct hb_iter_t
iter_t operator ++ (int) { iter_t c (*thiz()); ++*thiz(); return c; }
iter_t operator - (unsigned count) const { auto c = thiz()->iter (); c -= count; return c; }
iter_t operator -- (int) { iter_t c (*thiz()); --*thiz(); return c; }
template <typename T>
iter_t& operator >> (T &v) { v = **thiz(); ++*thiz(); return *thiz(); }
template <typename T>
iter_t& operator << (const T v) { **thiz() = v; ++*thiz(); return *thiz(); }
protected:
hb_iter_t () {}

View File

@ -149,5 +149,9 @@ main (int argc, char **argv)
| hb_filter (hb_bool, hb_identity)
;
t << 1;
long vl;
s >> vl;
return 0;
}