Extending llvm::iterator_range


Our llvm::iterator_range is quite minimalist in design, it does not even have an “empty” method.
Is that because we want it to work on all iterators (including those dirty OutputIterator)?

Maybe we can add a little bit to it?

I recently needed:

  • bool empty()
  • value_type& font()
  • value_type& back()
  • void advance_begin(difference_type n)
  • void advance_end(difference_type n)

Would you be open to those?

I’d prefer not to add these to iterator_range itself, but as free functions so they work on any range, including arrays, etc.

the advance_* ones, (is that the canonical/common name for those? I’d have guessed ‘slice’) could be free functions over arbitrary ranges that return iterator ranges, perhaps (though that gets into tricky territory, admittedly - lifetime expectations, views versus concrete/value ranges, etc)

I’m taking inspiration from those:


To me, “slice” would cut the range (intuitively). But I’m not an English native.