diff --git a/container/DynamicFIFO.h b/container/DynamicFIFO.h index 3a5242c7..fca4c8e8 100644 --- a/container/DynamicFIFO.h +++ b/container/DynamicFIFO.h @@ -18,7 +18,7 @@ template class DynamicFIFO: public FIFOBase { public: DynamicFIFO(size_t maxCapacity): FIFOBase(values.data(), maxCapacity), - values(maxCapacity) {}; + values(maxCapacity) {}; private: std::vector values; diff --git a/container/FIFOBase.h b/container/FIFOBase.h index 8bdb333f..082c596a 100644 --- a/container/FIFOBase.h +++ b/container/FIFOBase.h @@ -3,6 +3,7 @@ #include #include +#include template class FIFOBase { @@ -43,6 +44,23 @@ public: bool full(); size_t size(); + FIFOBase(const FIFOBase& other): readIndex(other.readIndex), + writeIndex(other.writeIndex), currentSize(other.currentSize), + maxCapacity(other.maxCapacity) { + std::memcpy(values, other.values, sizeof(T) * currentSize); + } + + FIFOBase& operator=(const FIFOBase& other) { + if(&other == this) + return *this; + maxCapacity = other.maxCapacity; + readIndex = other.readIndex; + writeIndex = other.writeIndex; + currentSize = other.currentSize; + std::memcpy(values, other.values, sizeof(T) * currentSize); + return *this; + } + size_t getMaxCapacity() const; private: