mirror of
https://gitlab.com/suyu-emu/suyu.git
synced 2024-03-15 23:15:44 +00:00
aes_util: Add static assertion to Transcode() and XTSTranscode() to ensure well-defined behavior
These functions should only be given trivially-copyable types.
This commit is contained in:
parent
64c8212ae1
commit
0d04ee97dc
|
@ -39,6 +39,8 @@ public:
|
||||||
|
|
||||||
template <typename Source, typename Dest>
|
template <typename Source, typename Dest>
|
||||||
void Transcode(const Source* src, size_t size, Dest* dest, Op op) const {
|
void Transcode(const Source* src, size_t size, Dest* dest, Op op) const {
|
||||||
|
static_assert(std::is_trivially_copyable_v<Source> && std::is_trivially_copyable_v<Dest>,
|
||||||
|
"Transcode source and destination types must be trivially copyable.");
|
||||||
Transcode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), op);
|
Transcode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), op);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +49,8 @@ public:
|
||||||
template <typename Source, typename Dest>
|
template <typename Source, typename Dest>
|
||||||
void XTSTranscode(const Source* src, size_t size, Dest* dest, size_t sector_id,
|
void XTSTranscode(const Source* src, size_t size, Dest* dest, size_t sector_id,
|
||||||
size_t sector_size, Op op) {
|
size_t sector_size, Op op) {
|
||||||
|
static_assert(std::is_trivially_copyable_v<Source> && std::is_trivially_copyable_v<Dest>,
|
||||||
|
"XTSTranscode source and destination types must be trivially copyable.");
|
||||||
XTSTranscode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), sector_id,
|
XTSTranscode(reinterpret_cast<const u8*>(src), size, reinterpret_cast<u8*>(dest), sector_id,
|
||||||
sector_size, op);
|
sector_size, op);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue