add resize to scoped buffer to allow better usage in the GP assignment
parent
3473247e6c
commit
ea31d8f26c
Before Width: | Height: | Size: 39 KiB After Width: | Height: | Size: 39 KiB |
Before Width: | Height: | Size: 118 KiB After Width: | Height: | Size: 118 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
@ -193,6 +193,21 @@ namespace blt
|
|||
return *this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resize the internal buffer. Nothing will occur if the sizes are equal.
|
||||
* This function WILL NOT COPY ANY DATA. It is meant for use when creating a scoped buffer without size.
|
||||
*/
|
||||
constexpr void resize(size_t size)
|
||||
{
|
||||
if (size == 0)
|
||||
return;
|
||||
if (size == size_)
|
||||
return;
|
||||
delete[] buffer_;
|
||||
buffer_ = new T[size];
|
||||
size_ = size;
|
||||
}
|
||||
|
||||
constexpr inline T& operator[](size_t index)
|
||||
{
|
||||
return buffer_[index];
|
||||
|
|
Loading…
Reference in New Issue