#ifndef BUFFER_H #define BUFFER_H #include template class Buffer { char data[N]; int length = 0; public: template Buffer& add(const T& t) { int bytes = N - length; if(bytes > static_cast (sizeof (T))) { bytes = sizeof (T); } memcpy(data + length, &t, bytes); length += bytes; return *this; } int getLength() const { return length; } operator const char*() const { return data; } }; #endif