// Copyright 2023 Citra Emulator Project // Licensed under GPLv2 or any later version // Refer to the license.txt file included. #pragma once #include #include #include #include "common/common_types.h" namespace Common { template class ScratchBuffer { static_assert(std::is_trivial_v, "Must use a POD type"); public: ScratchBuffer(std::size_t size_) : size{size_} { buffer = std::unique_ptr(new typename std::remove_extent::type[size]); } [[nodiscard]] std::size_t Size() const noexcept { return size; } [[nodiscard]] T* Data() const noexcept { return buffer.get(); } [[nodiscard]] std::span Span() const noexcept { return std::span{buffer.get(), size}; } private: std::unique_ptr buffer; std::size_t size; }; } // namespace Common