bugfixes
This commit is contained in:
@ -17,11 +17,26 @@
|
||||
template<typename T>
|
||||
class DynamicFIFO: public FIFOBase<T> {
|
||||
public:
|
||||
DynamicFIFO(size_t maxCapacity): FIFOBase<T>(values.data(), maxCapacity),
|
||||
values(maxCapacity) {};
|
||||
DynamicFIFO(size_t maxCapacity): FIFOBase<T>(nullptr, maxCapacity),
|
||||
fifoVector(maxCapacity) {
|
||||
// trying to pass the pointer of the uninitialized vector
|
||||
// to the FIFOBase constructor directly lead to a super evil bug.
|
||||
// So we do it like this now.
|
||||
this->setData(fifoVector.data());
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Custom copy constructor which prevents setting the
|
||||
* underlying pointer wrong.
|
||||
*/
|
||||
DynamicFIFO(const DynamicFIFO& other): FIFOBase<T>(other),
|
||||
fifoVector(other.maxCapacity) {
|
||||
this->setData(fifoVector.data());
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
std::vector<T> values;
|
||||
std::vector<T> fifoVector;
|
||||
};
|
||||
|
||||
#endif /* FRAMEWORK_CONTAINER_DYNAMICFIFO_H_ */
|
||||
|
Reference in New Issue
Block a user