2022-04-23 10:59:50 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-11-20 05:52:37 +01:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
|
|
|
|
template <typename To, typename From>
|
|
|
|
[[nodiscard]] std::enable_if_t<sizeof(To) == sizeof(From) && std::is_trivially_copyable_v<From> &&
|
|
|
|
std::is_trivially_copyable_v<To>,
|
|
|
|
To>
|
|
|
|
BitCast(const From& src) noexcept {
|
|
|
|
To dst;
|
|
|
|
std::memcpy(&dst, &src, sizeof(To));
|
|
|
|
return dst;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Common
|