[GIT] ppl/ppl(master): Added any_iterator operator+= and operator+ overloadings for unsigned types.

Module: ppl/ppl Branch: master Commit: 4abb9c3094dc31615447801e02e71ac6c4af1ff4 URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=4abb9c3094dc3...
Author: Enea Zaffanella zaffanella@cs.unipr.it Date: Fri Feb 24 16:09:55 2012 +0100
Added any_iterator operator+= and operator+ overloadings for unsigned types.
---
src/OR_Matrix.defs.hh | 10 ++++++++++ src/OR_Matrix.inlines.hh | 31 +++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/src/OR_Matrix.defs.hh b/src/OR_Matrix.defs.hh index 0c7f137..f70dca1 100644 --- a/src/OR_Matrix.defs.hh +++ b/src/OR_Matrix.defs.hh @@ -253,6 +253,11 @@ private: //! Assignment-increment operator. any_row_iterator& operator+=(difference_type m);
+ //! Assignment-increment operator for \p m of unsigned type. + template <typename Unsigned> + typename Enable_If<(static_cast<Unsigned>(-1) > 0), any_row_iterator&>::type + operator+=(Unsigned m); + //! Assignment-decrement operator. any_row_iterator& operator-=(difference_type m);
@@ -262,6 +267,11 @@ private: //! Returns the sum of \p *this and \p m. any_row_iterator operator+(difference_type m) const;
+ //! Returns the sum of \p *this and \p m, for \p m of unsigned type. + template <typename Unsigned> + typename Enable_If<(static_cast<Unsigned>(-1) > 0), any_row_iterator>::type + operator+(Unsigned m) const; + //! Returns the difference of \p *this and \p m. any_row_iterator operator-(difference_type m) const;
diff --git a/src/OR_Matrix.inlines.hh b/src/OR_Matrix.inlines.hh index 448bc0b..7a20e71 100644 --- a/src/OR_Matrix.inlines.hh +++ b/src/OR_Matrix.inlines.hh @@ -257,6 +257,25 @@ OR_Matrix<T>::any_row_iterator<U>::operator+=(const difference_type m) {
template <typename T> template <typename U> +template <typename Unsigned> +inline typename +Enable_If<(static_cast<Unsigned>(-1) > 0), + typename OR_Matrix<T>::template any_row_iterator<U>& >::type +OR_Matrix<T>::any_row_iterator<U>::operator+=(Unsigned m) { + dimension_type increment = m + m * m / 2 + m * e; + if (e % 2 == 0 && m % 2 != 0) + ++increment; + e += m; + i += increment; + value.first += increment; +#if PPL_OR_MATRIX_EXTRA_DEBUG + value.size_ = value.size_ + m - m % 2; +#endif + return *this; +} + +template <typename T> +template <typename U> inline typename OR_Matrix<T>::template any_row_iterator<U>& OR_Matrix<T>::any_row_iterator<U>::operator-=(difference_type m) { return *this += -m; @@ -280,6 +299,18 @@ OR_Matrix<T>::any_row_iterator<U>::operator+(difference_type m) const {
template <typename T> template <typename U> +template <typename Unsigned> +inline typename +Enable_If<(static_cast<Unsigned>(-1) > 0), + typename OR_Matrix<T>::template any_row_iterator<U> >::type +OR_Matrix<T>::any_row_iterator<U>::operator+(Unsigned m) const { + any_row_iterator r = *this; + r += m; + return r; +} + +template <typename T> +template <typename U> inline typename OR_Matrix<T>::template any_row_iterator<U> OR_Matrix<T>::any_row_iterator<U>::operator-(const difference_type m) const { any_row_iterator r = *this;
participants (1)
-
Enea Zaffanella