BLI: add index_range method to some data structures

This can be used to iterate over all indices with less code.
This commit is contained in:
2020-02-07 17:23:25 +01:00
parent f3db5a0965
commit c2e80cfaa3
4 changed files with 23 additions and 0 deletions

View File

@@ -246,6 +246,11 @@ template<typename T> class ArrayRef {
return fallback;
}
IndexRange index_range() const
{
return IndexRange(m_size);
}
/**
* Get a new array ref to the same underlying memory buffer. No conversions are done.
* Asserts when the sizes of the types don't match.
@@ -411,6 +416,11 @@ template<typename T> class MutableArrayRef {
{
return ArrayRef<T>(m_start, m_size);
}
IndexRange index_range() const
{
return IndexRange(m_size);
}
};
/**