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
+13 -11
View File
@@ -292,18 +292,20 @@ 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 { std::size_t WriteBuffer(const T& data, std::size_t buffer_index = 0) const {
if constexpr (std::contiguous_iterator<typename T::iterator>) { using C = typename T::value_type;
using ContiguousType = typename T::value_type; static_assert(std::is_trivially_copyable_v<C>, "Container to WriteBuffer must contain trivially copyable objects");
static_assert(std::is_trivially_copyable_v<ContiguousType>, return WriteBuffer(std::data(data), std::size(data) * sizeof(C), buffer_index);
"Container to WriteBuffer must contain trivially copyable objects"); }
return WriteBuffer(std::data(data), std::size(data) * sizeof(ContiguousType), template <typename T>
buffer_index); requires !std::is_pointer_v<T>
} else { && !std::contiguous_iterator<typename T::iterator>
static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable"); std::size_t WriteBuffer(const T& data, std::size_t buffer_index = 0) const {
return WriteBuffer(&data, sizeof(T), buffer_index); static_assert(std::is_trivially_copyable_v<T>, "T must be trivially copyable");
} 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