improved index out of range diagnostics
This commit is contained in:
4
vec.h
4
vec.h
@@ -620,6 +620,7 @@ template <typename T>
|
||||
inline T& NRVec_from1<T>::operator[](const int i) {
|
||||
#ifdef DEBUG
|
||||
if(_LA_count_check && *NRVec<T>::count != 1) laerror("possible use of NRVec[] with count>1 as l-value");
|
||||
if(i<1||i > NRVec<T>::nn) std::cout<<"INDEX PROBLEM "<<1<<" "<<i<<" "<< NRVec<T>::nn<<std::endl;
|
||||
if(i < 1) laerror("out of range - low");
|
||||
if(i > NRVec<T>::nn) laerror("out of range - high");
|
||||
if(!NRVec<T>::v) laerror("unallocated NRVec");
|
||||
@@ -638,6 +639,7 @@ inline T& NRVec_from1<T>::operator[](const int i) {
|
||||
template <typename T>
|
||||
inline const T& NRVec_from1<T>::operator[](const int i) const {
|
||||
#ifdef DEBUG
|
||||
if(i<1||i > NRVec<T>::nn) std::cout<<"INDEX PROBLEM "<<1<<" "<<i<<" "<< NRVec<T>::nn<<std::endl;
|
||||
if(i < 1) laerror("out of range - low");
|
||||
if(i > NRVec<T>::nn) laerror("out of range - high");
|
||||
if(!NRVec<T>::v) laerror("unallocated NRVec");
|
||||
@@ -1082,6 +1084,7 @@ template <typename T>
|
||||
inline T& NRVec<T>::operator[](const int i) {
|
||||
#ifdef DEBUG
|
||||
if(_LA_count_check && *count != 1) laerror("possible use of NRVec[] with count>1 as l-value");
|
||||
if(i<0||i >= nn) std::cout<<"INDEX PROBLEM "<<0<<" "<<i<<" "<<nn-1<<std::endl;
|
||||
if(i < 0) laerror("out of range - low");
|
||||
if(i >= nn) laerror("out of range - high");
|
||||
if(!v) laerror("unallocated NRVec");
|
||||
@@ -1100,6 +1103,7 @@ inline T& NRVec<T>::operator[](const int i) {
|
||||
template <typename T>
|
||||
inline const T& NRVec<T>::operator[](const int i) const {
|
||||
#ifdef DEBUG
|
||||
if(i<0||i >= nn) std::cout<<"INDEX PROBLEM "<<0<<" "<<i<<" "<<nn-1<<std::endl;
|
||||
if(i < 0) laerror("out of range - low");
|
||||
if(i >= nn) laerror("out of range - high");
|
||||
if(!v) laerror("unallocated NRVec");
|
||||
|
||||
Reference in New Issue
Block a user