Skip to content

Commit 4a529cd

Browse files
committed
Return reference on iterator indirection/subscript
1 parent e3844e0 commit 4a529cd

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

modules/core/include/opencv2/core/mat.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2880,9 +2880,9 @@ class MatConstIterator_ : public MatConstIterator
28802880
//! copy operator
28812881
MatConstIterator_& operator = (const MatConstIterator_& it);
28822882
//! returns the current matrix element
2883-
_Tp operator *() const;
2883+
const _Tp& operator *() const;
28842884
//! returns the i-th matrix element, relative to the current
2885-
_Tp operator [](ptrdiff_t i) const;
2885+
const _Tp& operator [](ptrdiff_t i) const;
28862886

28872887
//! shifts the iterator forward by the specified number of elements
28882888
MatConstIterator_& operator += (ptrdiff_t ofs);

modules/core/include/opencv2/core/mat.inl.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,7 +2550,7 @@ MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator = (const MatConstIterat
25502550
}
25512551

25522552
template<typename _Tp> inline
2553-
_Tp MatConstIterator_<_Tp>::operator *() const
2553+
const _Tp& MatConstIterator_<_Tp>::operator *() const
25542554
{
25552555
return *(_Tp*)(this->ptr);
25562556
}
@@ -2656,7 +2656,7 @@ MatConstIterator_<_Tp> operator - (const MatConstIterator_<_Tp>& a, ptrdiff_t of
26562656
}
26572657

26582658
template<typename _Tp> inline
2659-
_Tp MatConstIterator_<_Tp>::operator [](ptrdiff_t i) const
2659+
const _Tp& MatConstIterator_<_Tp>::operator [](ptrdiff_t i) const
26602660
{
26612661
return *(_Tp*)MatConstIterator::operator [](i);
26622662
}

0 commit comments

Comments
 (0)