diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H index c3b09850f964a78082df6286505c06656ae4946b..055f785471b909e9ee65c324d2d62bfb23b1777c 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedListI.H @@ -152,17 +152,12 @@ inline void Foam::FixedList<T, Size>::checkSize(const label size) const } -// Check index i is within valid range (0 ... size-1). +// Check index i is within valid range (0 ... size-1) +// The check for zero-sized list is already done in static assert template<class T, unsigned Size> inline void Foam::FixedList<T, Size>::checkIndex(const label i) const { - if (!Size) - { - FatalErrorIn("FixedList<T, Size>::checkIndex(const label)") - << "attempt to access element from zero-sized list" - << abort(FatalError); - } - else if (i < 0 || i >= label(Size)) + if (i < 0 || unsigned(i) >= Size) { FatalErrorIn("FixedList<T, Size>::checkIndex(const label)") << "index " << i << " out of range 0 ... " << (Size-1) diff --git a/src/OpenFOAM/containers/Lists/List/List.C b/src/OpenFOAM/containers/Lists/List/List.C index a3c17a48900dd57ec15e880260820258b32b18c3..6d20e2b3b72af3b5ec441d8c88668f2c9158b83c 100644 --- a/src/OpenFOAM/containers/Lists/List/List.C +++ b/src/OpenFOAM/containers/Lists/List/List.C @@ -58,10 +58,6 @@ Foam::List<T>::List(const label s) { this->v_ = new T[this->size_]; } - else - { - this->v_ = 0; - } } @@ -87,10 +83,6 @@ Foam::List<T>::List(const label s, const T& a) List_ELEM((*this), vp, i) = a; List_END_FOR_ALL } - else - { - this->v_ = 0; - } } @@ -119,16 +111,12 @@ Foam::List<T>::List(const List<T>& a) List_END_FOR_ALL } } - else - { - this->v_ = 0; - } } // Construct by transferring the parameter contents template<class T> -Foam::List<T>::List(const Xfer<List<T> >& lst) +Foam::List<T>::List(const Xfer< List<T> >& lst) { transfer(lst()); } @@ -165,10 +153,6 @@ Foam::List<T>::List(List<T>& a, bool reUse) List_END_FOR_ALL } } - else - { - this->v_ = 0; - } } @@ -188,10 +172,6 @@ Foam::List<T>::List(const UList<T>& a, const unallocLabelList& map) List_ELEM((*this), vp, i) = List_ELEM(a, ap, (map[i])); List_END_FOR_ALL } - else - { - this->v_ = 0; - } } @@ -234,7 +214,7 @@ Foam::List<T>::List(const FixedList<T, Size>& lst) : UList<T>(NULL, Size) { - if (Size) + if (this->size_) { this->v_ = new T[this->size_]; @@ -243,10 +223,6 @@ Foam::List<T>::List(const FixedList<T, Size>& lst) this->operator[](i) = lst[i]; } } - else - { - this->v_ = 0; - } } @@ -265,10 +241,6 @@ Foam::List<T>::List(const PtrList<T>& lst) this->operator[](i) = lst[i]; } } - else - { - this->v_ = 0; - } } @@ -293,10 +265,6 @@ Foam::List<T>::List(const SLList<T>& lst) this->operator[](i++) = iter(); } } - else - { - this->v_ = 0; - } } @@ -315,10 +283,6 @@ Foam::List<T>::List(const IndirectList<T>& lst) this->operator[](i) = lst[i]; } } - else - { - this->v_ = 0; - } } @@ -337,10 +301,6 @@ Foam::List<T>::List(const UIndirectList<T>& lst) this->operator[](i) = lst[i]; } } - else - { - this->v_ = 0; - } } @@ -359,10 +319,6 @@ Foam::List<T>::List(const BiIndirectList<T>& lst) this->operator[](i) = lst[i]; } } - else - { - this->v_ = 0; - } }