add default constructor to scoped_buffer

v1
Brett 2023-10-27 14:26:31 -04:00
parent 55c497475e
commit f639b4f83c
1 changed files with 6 additions and 1 deletions

View File

@ -26,7 +26,9 @@
#define SWAP32(val) bswap_32(val) #define SWAP32(val) bswap_32(val)
#define SWAP64(val) bswap_64(val) #define SWAP64(val) bswap_64(val)
#if __cplusplus >= 202002L #if __cplusplus >= 202002L
#include <bit> #include <bit>
#define ENDIAN_LOOKUP(little_endian) (std::endian::native == std::endian::little && !little_endian) || \ #define ENDIAN_LOOKUP(little_endian) (std::endian::native == std::endian::little && !little_endian) || \
(std::endian::native == std::endian::big && little_endian) (std::endian::native == std::endian::big && little_endian)
#else #else
@ -160,7 +162,7 @@ namespace blt
/** /**
* Creates an encapsulation of a T array which will be automatically deleted when this object goes out of scope. * Creates an encapsulation of a T array which will be automatically deleted when this object goes out of scope.
* This is a simple buffer meant to be used only inside of a function and not moved around, with a few minor exceptions. * This is a simple buffer meant to be used only inside of a function and not copied around.
* The internal buffer is allocated on the heap. * The internal buffer is allocated on the heap.
* The operator * has been overloaded to return the internal buffer. * The operator * has been overloaded to return the internal buffer.
* @tparam T type that is stored in buffer eg char * @tparam T type that is stored in buffer eg char
@ -172,6 +174,9 @@ namespace blt
T* _buffer; T* _buffer;
size_t _size; size_t _size;
public: public:
scoped_buffer(): _size(0), _buffer(nullptr)
{}
explicit scoped_buffer(size_t size): _size(size) explicit scoped_buffer(size_t size): _size(size)
{ {
_buffer = new T[size]; _buffer = new T[size];