From ecc4bdf11a2144f37e20631c17f3d58132499398 Mon Sep 17 00:00:00 2001 From: Steffen Gaisser Date: Wed, 30 Sep 2020 12:50:52 +0200 Subject: [PATCH] Added a compile time check for MAX_SIZE Compiler may warn if MAX_SIZE value overflows by itself but this checks gives a more verbose warning --- container/FixedArrayList.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/container/FixedArrayList.h b/container/FixedArrayList.h index 42b59177..505097c9 100644 --- a/container/FixedArrayList.h +++ b/container/FixedArrayList.h @@ -2,11 +2,13 @@ #define FIXEDARRAYLIST_H_ #include "ArrayList.h" +#include /** * \ingroup container */ -template +template class FixedArrayList: public ArrayList { + static_assert(MAX_SIZE <= (pow(2,sizeof(count_t)*8)-1), "count_t is not large enough to hold MAX_SIZE"); private: T data[MAX_SIZE]; public: