#pragma once #include // common types using u8 = std::uint8_t; using i8 = std::int8_t; using u16 = std::uint16_t; using i16 = std::int16_t; using u32 = std::uint32_t; using i32 = std::int32_t; using u64 = std::uint64_t; using i64 = std::int64_t; using usize = std::size_t; using f32 = float; using f64 = double; /// like vector but doesn't grow on its own template struct unique_buffer { T* m_buffer; size_t size; public: unique_buffer() { m_buffer = nullptr; size = 0; } // forbid copying or movement for now unique_buffer(const unique_buffer&) = delete; unique_buffer(unique_buffer&&) = delete; ~unique_buffer() { resize(0); } size_t get_size() const { return this->size; } void resize(size_t new_size) { if(m_buffer) { delete[] m_buffer; m_buffer = nullptr; size = 0; } if(new_size) { m_buffer = new T[new_size]; size = new_size; } } T* data() { return &m_buffer[0]; } const T* data() const { return &m_buffer[0]; } };