diff options
Diffstat (limited to 'src/common.h')
-rw-r--r-- | src/common.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common.h b/src/common.h index 1f8ad771..d489d05d 100644 --- a/src/common.h +++ b/src/common.h @@ -100,6 +100,14 @@ static const Address kInvalidAddress = ~0; static const Index kInvalidIndex = ~0; static const Offset kInvalidOffset = ~0; +template <typename Dst, typename Src> +Dst Bitcast(Src value) { + static_assert(sizeof(Src) == sizeof(Dst), "Bitcast sizes must match."); + Dst result; + memcpy(&result, &value, sizeof(result)); + return result; +} + template<typename T> void ZeroMemory(T& v) { WABT_STATIC_ASSERT(std::is_pod<T>::value); |