From f433d1c4c3e3ed1400489df8f8d5c6b7a3d41624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 19 Mar 2024 15:32:34 -0700 Subject: [PATCH] Cleanup. --- include/bx/bx.h | 4 ++-- include/bx/inline/bx.inl | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/bx/bx.h b/include/bx/bx.h index 79eff13..728d2d8 100644 --- a/include/bx/bx.h +++ b/include/bx/bx.h @@ -215,8 +215,8 @@ namespace bx constexpr bool isPowerOf2(Ty _a); /// Returns a value of type To by reinterpreting the object representation of From. - template - constexpr To bit_cast(const From& value) noexcept; + template + constexpr Ty bit_cast(const FromT& _from); /// Copy memory block. /// diff --git a/include/bx/inline/bx.inl b/include/bx/inline/bx.inl index 46c6c7e..09a2ddb 100644 --- a/include/bx/inline/bx.inl +++ b/include/bx/inline/bx.inl @@ -147,14 +147,14 @@ namespace bx return _a && !(_a & (_a - 1) ); } - template - inline constexpr To bit_cast(const From& value) noexcept + template + inline constexpr Ty bit_cast(const FromT& _from) { - BX_STATIC_ASSERT(sizeof(To) == sizeof(From), "To and From must be the same size."); - BX_STATIC_ASSERT(isTriviallyConstructible(), "Destination target must be trivially constructible."); - To result; - bx::memCopy(&result, &value, sizeof(To)); - return result; + static_assert(sizeof(Ty) == sizeof(FromT), "Ty and FromT must be the same size."); + static_assert(isTriviallyConstructible(), "Destination target must be trivially constructible."); + Ty to; + bx::memCopy(&to, &_from, sizeof(Ty) ); + return to; } } // namespace bx