These are chat archives for fmtlib/fmt

26th
Sep 2018
Victor Zverovich
@vitaut
Sep 26 2018 00:13
Good catch! It should be easy to fix by passing the character type as an extra parameter to truncating_iterator. PRs are welcome =)
lyngklip
@lyngklip
Sep 26 2018 08:07
I had it working by rewriting the ++, --, * operators and adding a = operator so the truncating_iterator works more like a back_inserting_iterator, but I didn't test with plain pointers, and I I'm not quite sure what I'm doing, so...
lyngklip
@lyngklip
Sep 26 2018 17:07
++(), --(), and *() for back_inserting_iterator do nothing and =() calls push_back, so the assignment actually advances the underlying iterator. I did similarly for the truncating_iterator so that --(), ++(), and *() do nothing but return *this, and assignment assigns to - and increments - the underlying iterator - if count hasn't reached limit yet. Something like if (count++ < limit) *out_++ = value;. As a template function, to avoid the issue of value_type. I'll see if I can figure out how to make a PR.
lyngklip
@lyngklip
Sep 26 2018 17:28
I realize that what I just wrote doesn't make sense, because back_insert_iterator doesn't have an underlying iterator. Also, if fmtlib assigns twice without advancing the iterator, my solution will fail because it will advance the iterator implicitly.