mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-10 00:41:26 +12:00
Make std::bit_cast hack-implementation constexpr in simple cases
This commit is contained in:
parent
07a44d0ff9
commit
58e2465369
2 changed files with 37 additions and 32 deletions
|
@ -94,6 +94,11 @@ namespace std
|
|||
{
|
||||
static_assert(sizeof(To) == sizeof(From), "std::bit_cast<>: incompatible type size");
|
||||
|
||||
if constexpr (std::is_same_v<std::remove_const_t<To>, std::remove_const_t<From>> || (std::is_integral_v<From> && std::is_integral_v<To>))
|
||||
{
|
||||
return static_cast<To>(from);
|
||||
}
|
||||
|
||||
To result{};
|
||||
std::memcpy(&result, &from, sizeof(From));
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue