Merge pull request #309 from lioncash/typename
cast_util: Remove unnecessary typename
This commit is contained in:
commit
c167715336
1 changed files with 2 additions and 2 deletions
|
@ -18,7 +18,7 @@ inline Dest BitCast(const Source& source) {
|
||||||
static_assert(std::is_trivially_copyable_v<Dest>, "destination type must be trivially copyable.");
|
static_assert(std::is_trivially_copyable_v<Dest>, "destination type must be trivially copyable.");
|
||||||
static_assert(std::is_trivially_copyable_v<Source>, "source type must be trivially copyable");
|
static_assert(std::is_trivially_copyable_v<Source>, "source type must be trivially copyable");
|
||||||
|
|
||||||
typename std::aligned_storage_t<sizeof(Dest), alignof(Dest)> dest;
|
std::aligned_storage_t<sizeof(Dest), alignof(Dest)> dest;
|
||||||
std::memcpy(&dest, &source, sizeof(dest));
|
std::memcpy(&dest, &source, sizeof(dest));
|
||||||
return reinterpret_cast<Dest&>(dest);
|
return reinterpret_cast<Dest&>(dest);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ inline Dest BitCastPointee(const SourcePtr source) {
|
||||||
static_assert(sizeof(SourcePtr) == sizeof(void*), "source pointer must have size of a pointer");
|
static_assert(sizeof(SourcePtr) == sizeof(void*), "source pointer must have size of a pointer");
|
||||||
static_assert(std::is_trivially_copyable_v<Dest>, "destination type must be trivially copyable.");
|
static_assert(std::is_trivially_copyable_v<Dest>, "destination type must be trivially copyable.");
|
||||||
|
|
||||||
typename std::aligned_storage_t<sizeof(Dest), alignof(Dest)> dest;
|
std::aligned_storage_t<sizeof(Dest), alignof(Dest)> dest;
|
||||||
std::memcpy(&dest, BitCast<void*>(source), sizeof(dest));
|
std::memcpy(&dest, BitCast<void*>(source), sizeof(dest));
|
||||||
return reinterpret_cast<Dest&>(dest);
|
return reinterpret_cast<Dest&>(dest);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue