#ifndef TYPEBUFFER_H #define TYPEBUFFER_H #include "utils/Buffer.h" template class TypedBuffer { Buffer data; public: TypedBuffer(int n) : data(static_cast(sizeof(T)) * n) { } TypedBuffer& add(const T& t) { data.add(t); return *this; } int getLength() const { return data.getLength() / static_cast(sizeof(T)); } int getByteLength() const { return data.getLength(); } operator const T*() const { return reinterpret_cast(static_cast(data)); } void clear() { data.clear(); } }; #endif