summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-04-13 02:40:40 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-04-15 22:23:02 +0300
commit1ad214dd1b353e79923ec6d6dfd4246759e99407 (patch)
tree230b68485c32562078b19730cd4348bf24210f42 /include
parentc244d07286e4010ee884eeea6f8e67fa5d1ff3cb (diff)
libcamera: span: Fix reverse iterators
std::reverse_iterator<iterator> is constructed from an instance of iterator, and automatically subtracts 1 when dereferencing. rbegin() and rend() should thus be constructed from end() and begin() respectively. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'include')
-rw-r--r--include/libcamera/span.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/include/libcamera/span.h b/include/libcamera/span.h
index 91e9f974..7a35806b 100644
--- a/include/libcamera/span.h
+++ b/include/libcamera/span.h
@@ -194,9 +194,9 @@ public:
constexpr const_iterator cbegin() const { return begin(); }
constexpr iterator end() const { return data() + size(); }
constexpr const_iterator cend() const { return end(); }
- constexpr reverse_iterator rbegin() const { return reverse_iterator(data() + size() - 1); }
+ constexpr reverse_iterator rbegin() const { return reverse_iterator(end()); }
constexpr const_reverse_iterator crbegin() const { return rbegin(); }
- constexpr reverse_iterator rend() const { return reverse_iterator(data() - 1); }
+ constexpr reverse_iterator rend() const { return reverse_iterator(begin()); }
constexpr const_reverse_iterator crend() const { return rend(); }
constexpr reference front() const { return *data(); }
@@ -360,9 +360,9 @@ public:
constexpr const_iterator cbegin() const { return begin(); }
constexpr iterator end() const { return data() + size(); }
constexpr const_iterator cend() const { return end(); }
- constexpr reverse_iterator rbegin() const { return reverse_iterator(data() + size() - 1); }
+ constexpr reverse_iterator rbegin() const { return reverse_iterator(end()); }
constexpr const_reverse_iterator crbegin() const { return rbegin(); }
- constexpr reverse_iterator rend() const { return reverse_iterator(data() - 1); }
+ constexpr reverse_iterator rend() const { return reverse_iterator(begin()); }
constexpr const_reverse_iterator crend() const { return rend(); }
constexpr reference front() const { return *data(); }