diff options
author | David <25727384+ogniK5377@users.noreply.github.com> | 2020-08-03 13:28:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-03 13:28:54 +0200 |
commit | 9b75481755c8d566bc666465d659115bba2b2578 (patch) | |
tree | 309d0ff37c8e68d178b65861abeb3bb0e8387f43 /src/core/hle/kernel/hle_ipc.h | |
parent | Merge pull request #4263 from lat9nq/fix-screencaps-2 (diff) | |
download | yuzu-9b75481755c8d566bc666465d659115bba2b2578.tar yuzu-9b75481755c8d566bc666465d659115bba2b2578.tar.gz yuzu-9b75481755c8d566bc666465d659115bba2b2578.tar.bz2 yuzu-9b75481755c8d566bc666465d659115bba2b2578.tar.lz yuzu-9b75481755c8d566bc666465d659115bba2b2578.tar.xz yuzu-9b75481755c8d566bc666465d659115bba2b2578.tar.zst yuzu-9b75481755c8d566bc666465d659115bba2b2578.zip |
Diffstat (limited to 'src/core/hle/kernel/hle_ipc.h')
-rw-r--r-- | src/core/hle/kernel/hle_ipc.h | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index b31673928..f3277b766 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -13,6 +13,7 @@ #include <vector> #include <boost/container/small_vector.hpp> #include "common/common_types.h" +#include "common/concepts.h" #include "common/swap.h" #include "core/hle/ipc.h" #include "core/hle/kernel/object.h" @@ -193,23 +194,24 @@ public: /* Helper function to write a buffer using the appropriate buffer descriptor * - * @tparam ContiguousContainer an arbitrary container that satisfies the - * ContiguousContainer concept in the C++ standard library. + * @tparam T an arbitrary container that satisfies the + * ContiguousContainer concept in the C++ standard library or a trivially copyable type. * - * @param container The container to write the data of into a buffer. + * @param data The container/data to write into a buffer. * @param buffer_index The buffer in particular to write to. */ - template <typename ContiguousContainer, - typename = std::enable_if_t<!std::is_pointer_v<ContiguousContainer>>> - std::size_t WriteBuffer(const ContiguousContainer& container, - std::size_t buffer_index = 0) const { - using ContiguousType = typename ContiguousContainer::value_type; - - static_assert(std::is_trivially_copyable_v<ContiguousType>, - "Container to WriteBuffer must contain trivially copyable objects"); - - return WriteBuffer(std::data(container), std::size(container) * sizeof(ContiguousType), - buffer_index); + template <typename T, typename = std::enable_if_t<!std::is_pointer_v<T>>> + std::size_t WriteBuffer(const T& data, std::size_t buffer_index = 0) const { + if constexpr (Common::IsSTLContainer<T>) { + 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"); + return WriteBuffer(&data, sizeof(T), buffer_index); + } } /// Helper function to get the size of the input buffer |