diff --git a/dl/base/dl_array2.h b/dl/base/dl_array2.h new file mode 100644 index 00000000..84103685 --- /dev/null +++ b/dl/base/dl_array2.h @@ -0,0 +1,76 @@ +/** +* @file dl_array2.h +* @brief 2维array +* +* +* @version 1.0 +* @author lveyou +* @date 23-07-09 +* +* @note 提供行指针,避免乘法计算 +* @note 设计为深拷贝,与std::array一致 +*/ +#pragma once + + +namespace dl +{ + +template +class Array2 +{ +public: + /** + * @brief 填充值 + */ + void Fill(const T& v) + { + for (auto& iter : _data) + iter = v; + } + + std::byte* GetBuffer() + { + return (std::byte*)_data.data(); + } + + T* GetData() + { + return _data.data(); + } + + unsigned GetWidth() + { + return (unsigned)W; + } + + unsigned GetHeight() + { + return (unsigned)H; + } + + Size GetSize() + { + return { (unsigned)W, (unsigned)H }; + } + + size_t GetSizeByte() + { + return _data.size() * sizeof(T); + } + + auto begin() + { + return _data.begin(); + } + auto end() + { + return _data.end(); + } +private: + std::array _data; + std::array _ptrRow; +}; + + +} \ No newline at end of file diff --git a/dl/dl_platform.h b/dl/dl_platform.h index a15c9fc9..17481956 100644 --- a/dl/dl_platform.h +++ b/dl/dl_platform.h @@ -34,7 +34,7 @@ consteval bool is_x64() return sizeof(void*) == 8; } -//! 是否小端 +//! 字节序是否小端 consteval bool is_little_endian() { union