NByteData.hpp
#include<array> #include<cstring> template<size_t SIZE> class NByteData { std::array<unsigned char, SIZE> m_data; public: using ThisT = NByteData<SIZE>; unsigned char* data() { return m_data.data(); }
ThisT& operator=(const ThisT& t) { for (size_t i = 0; i < m_data.size(); i++) { m_data[i] = t.m_data[i]; } return *this; }
bool operator==(const ThisT& t)const { for (size_t i = 0; i < SIZE; i++) { if (m_data[i] != t.m_data[i]) return false; } return true; }
bool operator!=(const ThisT& t)const { return !this->operator==(t); }
NByteData() {}
NByteData(const ThisT& src) { this->operator=(src); }
NByteData(std::initializer_list<unsigned char> inits) { unsigned char* p = m_data.data(); for (auto uc : inits) { *p = uc; ++p; } }
};