2026-09-17 15:19:28

Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
lizzie
2026-09-17 15:19:28 +00:00
parent 710c97dea8
commit c3bf576df1
+11 -9
View File
@@ -292,19 +292,21 @@ public:
* @param data The container/data to write into a buffer. * @param data The container/data to write into a buffer.
* @param buffer_index The buffer in particular to write to. * @param buffer_index The buffer in particular to write to.
*/ */
template <typename T, typename = std::enable_if_t<!std::is_pointer_v<T>>> template <typename T>
requires !std::is_pointer_v<T>
&& std::contiguous_iterator<typename T::iterator>
std::size_t WriteBuffer(const T& data, std::size_t buffer_index = 0) const {
using C = typename T::value_type;
static_assert(std::is_trivially_copyable_v<C>, "Container to WriteBuffer must contain trivially copyable objects");
return WriteBuffer(std::data(data), std::size(data) * sizeof(C), buffer_index);
}
template <typename T>
requires !std::is_pointer_v<T>
&& !std::contiguous_iterator<typename T::iterator>
std::size_t WriteBuffer(const T& data, std::size_t buffer_index = 0) const { std::size_t WriteBuffer(const T& data, std::size_t buffer_index = 0) const {
if constexpr (std::contiguous_iterator<typename T::iterator>) {
using ContiguousType = typename T::value_type;
static_assert(std::is_trivially_copyable_v<ContiguousType>,
"Container to WriteBuffer must contain trivially copyable objects");
return WriteBuffer(std::data(data), std::size(data) * sizeof(ContiguousType),
buffer_index);
} else {
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable"); static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable");
return WriteBuffer(&data, sizeof(T), buffer_index); return WriteBuffer(&data, sizeof(T), buffer_index);
} }
}
/// Helper function to get the size of the input buffer /// Helper function to get the size of the input buffer
[[nodiscard]] std::size_t GetReadBufferSize(std::size_t buffer_index = 0) const; [[nodiscard]] std::size_t GetReadBufferSize(std::size_t buffer_index = 0) const;