aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/make_unique_for_overwrite.h27
-rw-r--r--src/common/scratch_buffer.h12
3 files changed, 6 insertions, 34 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 94da1724df..0517f0b9e1 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -76,7 +76,6 @@ add_library(
logging.h
lz4_compression.cpp
lz4_compression.h
- make_unique_for_overwrite.h
math_util.h
memory_detect.cpp
memory_detect.h
diff --git a/src/common/make_unique_for_overwrite.h b/src/common/make_unique_for_overwrite.h
deleted file mode 100644
index 17f81bba4a..0000000000
--- a/src/common/make_unique_for_overwrite.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
-// SPDX-License-Identifier: GPL-2.0-or-later
-
-#pragma once
-
-#include <memory>
-#include <type_traits>
-
-namespace Common {
-
-template <class T>
- requires(!std::is_array_v<T>)
-std::unique_ptr<T> make_unique_for_overwrite() {
- return std::unique_ptr<T>(new T);
-}
-
-template <class T>
- requires std::is_unbounded_array_v<T>
-std::unique_ptr<T> make_unique_for_overwrite(std::size_t n) {
- return std::unique_ptr<T>(new std::remove_extent_t<T>[n]);
-}
-
-template <class T, class... Args>
- requires std::is_bounded_array_v<T>
-void make_unique_for_overwrite(Args&&...) = delete;
-
-} // namespace Common
diff --git a/src/common/scratch_buffer.h b/src/common/scratch_buffer.h
index 8c1f566301..929a65609a 100644
--- a/src/common/scratch_buffer.h
+++ b/src/common/scratch_buffer.h
@@ -8,8 +8,7 @@
#include <iterator>
#include <cstring>
-
-#include "common/make_unique_for_overwrite.h"
+#include <memory>
namespace Common {
@@ -38,8 +37,9 @@ public:
ScratchBuffer() = default;
explicit ScratchBuffer(size_type initial_capacity)
- : last_requested_size{initial_capacity}, buffer_capacity{initial_capacity},
- buffer{Common::make_unique_for_overwrite<T[]>(initial_capacity)} {}
+ : last_requested_size{initial_capacity}
+ , buffer_capacity{initial_capacity}
+ , buffer{std::make_unique_for_overwrite<T[]>(initial_capacity)} {}
~ScratchBuffer() = default;
ScratchBuffer(const ScratchBuffer&) = delete;
@@ -64,7 +64,7 @@ public:
/// The previously held data will remain intact.
void resize(size_type size) {
if (size > buffer_capacity) {
- auto new_buffer = Common::make_unique_for_overwrite<T[]>(size);
+ auto new_buffer = std::make_unique_for_overwrite<T[]>(size);
std::memcpy(new_buffer.get(), buffer.get(), buffer_capacity * sizeof(T));
buffer = std::move(new_buffer);
buffer_capacity = size;
@@ -77,7 +77,7 @@ public:
void resize_destructive(size_type size) {
if (size > buffer_capacity) {
buffer_capacity = size;
- buffer = Common::make_unique_for_overwrite<T[]>(buffer_capacity);
+ buffer = std::make_unique_for_overwrite<T[]>(buffer_capacity);
}
last_requested_size = size;
}