2022-04-23 04:59:50 -04:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-11-19 23:52:37 -05:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-03-07 19:53:32 -05:00
|
|
|
#include <version>
|
|
|
|
|
|
|
|
#ifdef __cpp_lib_bit_cast
|
|
|
|
#include <bit>
|
|
|
|
#endif
|
2020-11-19 23:52:37 -05:00
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
|
|
|
|
template <typename To, typename From>
|
2023-03-07 19:53:32 -05:00
|
|
|
constexpr inline To BitCast(const From& from) {
|
|
|
|
#ifdef __cpp_lib_bit_cast
|
|
|
|
return std::bit_cast<To>(from);
|
|
|
|
#else
|
|
|
|
return __builtin_bit_cast(To, from);
|
|
|
|
#endif
|
2020-11-19 23:52:37 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Common
|