BLI: improve IndexRange
Defining `operator-` for the iterator allows it to be used in more generic iterator code. The `index_range` method is the same that exists on many other containers like `Vector`.
This commit is contained in:
@@ -105,6 +105,11 @@ class IndexRange {
|
||||
return a.current_ == b.current_;
|
||||
}
|
||||
|
||||
constexpr friend int64_t operator-(const Iterator &a, const Iterator &b)
|
||||
{
|
||||
return a.current_ - b.current_;
|
||||
}
|
||||
|
||||
constexpr int64_t operator*() const
|
||||
{
|
||||
return current_;
|
||||
@@ -151,6 +156,11 @@ class IndexRange {
|
||||
return size_;
|
||||
}
|
||||
|
||||
constexpr IndexRange index_range() const
|
||||
{
|
||||
return IndexRange(size_);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the size is zero.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user