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
This commit is contained in:
parent
5340b9c58e
commit
ecc4bdf11a
@ -2,11 +2,13 @@
|
|||||||
#define FIXEDARRAYLIST_H_
|
#define FIXEDARRAYLIST_H_
|
||||||
|
|
||||||
#include "ArrayList.h"
|
#include "ArrayList.h"
|
||||||
|
#include <cmath>
|
||||||
/**
|
/**
|
||||||
* \ingroup container
|
* \ingroup container
|
||||||
*/
|
*/
|
||||||
template<typename T, uint32_t MAX_SIZE, typename count_t = uint8_t>
|
template<typename T, size_t MAX_SIZE, typename count_t = uint8_t>
|
||||||
class FixedArrayList: public ArrayList<T, count_t> {
|
class FixedArrayList: public ArrayList<T, count_t> {
|
||||||
|
static_assert(MAX_SIZE <= (pow(2,sizeof(count_t)*8)-1), "count_t is not large enough to hold MAX_SIZE");
|
||||||
private:
|
private:
|
||||||
T data[MAX_SIZE];
|
T data[MAX_SIZE];
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user