Refactor List operator[] to prevent compiler warnings.

Prevents GCC compiler throwing: control reaches end of non-void function.
Prevents Visual Studio throwing C4715: not all control paths return a value.
This commit is contained in:
Marcel Admiraal 2020-02-11 07:53:33 +01:00
parent 6fb6405408
commit 07d21b84a3

View File

@ -456,17 +456,12 @@ public:
Element *I = front();
int c = 0;
while (I) {
if (c == p_index) {
return I->get();
}
while (c < p_index) {
I = I->next();
c++;
}
CRASH_NOW(); // bug!!
return I->get();
}
const T &operator[](int p_index) const {
@ -475,17 +470,12 @@ public:
const Element *I = front();
int c = 0;
while (I) {
if (c == p_index) {
return I->get();
}
while (c < p_index) {
I = I->next();
c++;
}
CRASH_NOW(); // bug!!
return I->get();
}
void move_to_back(Element *p_I) {