diff --git a/include/ebcl/inline/Arrays.hh b/include/ebcl/inline/Arrays.hh index 29576d1..f8a9401 100644 --- a/include/ebcl/inline/Arrays.hh +++ b/include/ebcl/inline/Arrays.hh @@ -709,31 +709,35 @@ M_HDR_ inline T& M_CNAME_::operator[]( M_HDR_ inline M_CNAME_T_& M_CNAME_::operator++ () noexcept { - assert( valid( ) ); - pos_ += D; + assert( array_ ); + pos_ = std::min( ptrdiff_t( array_->size( ) ) , + std::max( ptrdiff_t( -1 ) , pos_ + D ) ); return *this; } M_HDR_ inline M_CNAME_T_ M_CNAME_::operator++ (int) noexcept { - assert( valid( ) ); + assert( array_ ); auto copy( *this ); - pos_ += D; + pos_ = std::min( ptrdiff_t( array_->size( ) ) , + std::max( ptrdiff_t( -1 ) , pos_ + D ) ); return copy; } M_HDR_ inline M_CNAME_T_& M_CNAME_::operator-- () noexcept { - assert( valid( ) ); - pos_ -= D; + assert( array_ ); + pos_ = std::min( ptrdiff_t( array_->size( ) ) , + std::max( ptrdiff_t( -1 ) , pos_ - D ) ); return *this; } M_HDR_ inline M_CNAME_T_ M_CNAME_::operator-- (int) noexcept { - assert( valid( ) ); + assert( array_ ); auto copy( *this ); - pos_ -= D; + pos_ = std::min( ptrdiff_t( array_->size( ) ) , + std::max( ptrdiff_t( -1 ) , pos_ - D ) ); return copy; } @@ -765,7 +769,7 @@ M_HDR_ inline ptrdiff_t M_CNAME_::operator -( M_HDR_ inline M_CNAME_T_& M_CNAME_::operator +=( const ptrdiff_t value ) noexcept { - assert( valid( ) ); + assert( array_ ); pos_ = std::min( ptrdiff_t( array_->size( ) ) , std::max( ptrdiff_t( -1 ) , pos_ + value * D ) ); return *this; @@ -774,7 +778,7 @@ M_HDR_ inline M_CNAME_T_& M_CNAME_::operator +=( M_HDR_ inline M_CNAME_T_& M_CNAME_::operator -=( const ptrdiff_t value ) noexcept { - assert( valid( ) ); + assert( array_ ); pos_ = std::min( ptrdiff_t( array_->size( ) ) , std::max( ptrdiff_t( -1 ) , pos_ - value * D ) ); return *this; @@ -912,31 +916,35 @@ M_HDR_ inline T const& M_CNAME_::operator[]( M_HDR_ inline M_CNAME_T_& M_CNAME_::operator++ () noexcept { - assert( valid( ) ); - pos_ += D; + assert( array_ ); + pos_ = std::min( ptrdiff_t( array_->size( ) ) , + std::max( ptrdiff_t( -1 ) , pos_ + D ) ); return *this; } M_HDR_ inline M_CNAME_T_ M_CNAME_::operator++ (int) noexcept { - assert( valid( ) ); + assert( array_ ); auto copy( *this ); - pos_ += D; + pos_ = std::min( ptrdiff_t( array_->size( ) ) , + std::max( ptrdiff_t( -1 ) , pos_ + D ) ); return copy; } M_HDR_ inline M_CNAME_T_& M_CNAME_::operator-- () noexcept { - assert( valid( ) ); - pos_ -= D; + assert( array_ ); + pos_ = std::min( ptrdiff_t( array_->size( ) ) , + std::max( ptrdiff_t( -1 ) , pos_ - D ) ); return *this; } M_HDR_ inline M_CNAME_T_ M_CNAME_::operator-- (int) noexcept { - assert( valid( ) ); + assert( array_ ); auto copy( *this ); - pos_ -= D; + pos_ = std::min( ptrdiff_t( array_->size( ) ) , + std::max( ptrdiff_t( -1 ) , pos_ - D ) ); return copy; } @@ -968,7 +976,7 @@ M_HDR_ inline ptrdiff_t M_CNAME_::operator -( M_HDR_ inline M_CNAME_T_& M_CNAME_::operator +=( const ptrdiff_t value ) noexcept { - assert( valid( ) ); + assert( array_ ); pos_ = std::min( ptrdiff_t( array_->size( ) ) , std::max( ptrdiff_t( -1 ) , pos_ + value * D ) ); return *this; @@ -977,7 +985,7 @@ M_HDR_ inline M_CNAME_T_& M_CNAME_::operator +=( M_HDR_ inline M_CNAME_T_& M_CNAME_::operator -=( const ptrdiff_t value ) noexcept { - assert( valid( ) ); + assert( array_ ); pos_ = std::min( ptrdiff_t( array_->size( ) ) , std::max( ptrdiff_t( -1 ) , pos_ - value * D ) ); return *this;