From 76beee62c3066db07598ea9538b6122d9c02f3d4 Mon Sep 17 00:00:00 2001 From: "Justin C. Miller" Date: Sun, 1 Aug 2021 14:27:56 -0700 Subject: [PATCH] [headers] Add const version counted's iterators To allow for use of a const counted, add const iterator versions of begin() and end() --- src/include/counted.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/include/counted.h b/src/include/counted.h index 0a6f12b..066b414 100644 --- a/src/include/counted.h +++ b/src/include/counted.h @@ -20,12 +20,19 @@ struct counted inline const T & operator [] (int i) const { return pointer[i]; } using iterator = offset_iterator; + using const_iterator = const_offset_iterator; /// Return an iterator to the beginning of the array inline iterator begin() { return iterator(pointer, sizeof(T)); } /// Return an iterator to the end of the array inline iterator end() { return offset_ptr(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(pointer, sizeof(T)*count); } }; /// Specialize for `void` which cannot be indexed or iterated