mirror of
https://github.com/justinian/jsix.git
synced 2025-12-10 08:24:32 -08:00
[headers] Add const version counted's iterators
To allow for use of a const counted<T>, add const iterator versions of begin() and end()
This commit is contained in:
@@ -20,12 +20,19 @@ struct counted
|
|||||||
inline const T & operator [] (int i) const { return pointer[i]; }
|
inline const T & operator [] (int i) const { return pointer[i]; }
|
||||||
|
|
||||||
using iterator = offset_iterator<T>;
|
using iterator = offset_iterator<T>;
|
||||||
|
using const_iterator = const_offset_iterator<T>;
|
||||||
|
|
||||||
/// Return an iterator to the beginning of the array
|
/// Return an iterator to the beginning of the array
|
||||||
inline iterator begin() { return iterator(pointer, sizeof(T)); }
|
inline iterator begin() { return iterator(pointer, sizeof(T)); }
|
||||||
|
|
||||||
/// Return an iterator to the end of the array
|
/// Return an iterator to the end of the array
|
||||||
inline iterator end() { return offset_ptr<T>(pointer, sizeof(T)*count); }
|
inline iterator end() { return offset_ptr<T>(pointer, sizeof(T)*count); }
|
||||||
|
|
||||||
|
/// Return an iterator to the beginning of the array
|
||||||
|
inline const_iterator begin() const { return const_iterator(pointer, sizeof(T)); }
|
||||||
|
|
||||||
|
/// Return an iterator to the end of the array
|
||||||
|
inline const_iterator end() const { return offset_ptr<const T>(pointer, sizeof(T)*count); }
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Specialize for `void` which cannot be indexed or iterated
|
/// Specialize for `void` which cannot be indexed or iterated
|
||||||
|
|||||||
Reference in New Issue
Block a user