diff --git a/src/util/Buffer.hpp b/src/util/Buffer.hpp index a721e646..cfc5451f 100644 --- a/src/util/Buffer.hpp +++ b/src/util/Buffer.hpp @@ -2,6 +2,7 @@ #include #include +#include namespace util { /// @brief Template similar to std::unique_ptr stores a buffer with its size @@ -26,6 +27,19 @@ namespace util { std::memcpy(ptr.get(), src, length); } + Buffer(std::initializer_list values) + : ptr(std::make_unique(values)), length(values.size()) {} + + Buffer(std::nullptr_t) noexcept : ptr(nullptr), length(0) {} + + inline bool operator==(std::nullptr_t) const noexcept { + return ptr == nullptr; + } + + inline bool operator!=(std::nullptr_t) const noexcept { + return ptr != nullptr; + } + T& operator[](long long index) { return ptr[index]; }