diff --git a/include/libimp/horrible_cast.h b/include/libimp/horrible_cast.h index 3939881..2128ed1 100644 --- a/include/libimp/horrible_cast.h +++ b/include/libimp/horrible_cast.h @@ -23,9 +23,8 @@ union temp { } // namespace detail_horrible_cast template -constexpr auto horrible_cast(U &&in) noexcept - -> std::enable_if_t<(sizeof(T) == sizeof(std::decay_t)), T> { - return detail_horrible_cast::temp>{std::forward(in)}.out; +constexpr T horrible_cast(U &&in) noexcept { + return detail_horrible_cast::temp{std::forward(in)}.out; } LIBIMP_NAMESPACE_END_ diff --git a/test/imp/test_imp_utility.cpp b/test/imp/test_imp_utility.cpp index 3c6ba5d..037683d 100644 --- a/test/imp/test_imp_utility.cpp +++ b/test/imp/test_imp_utility.cpp @@ -143,7 +143,11 @@ TEST(utility, horrible_cast) { EXPECT_EQ(b.a_[0], 0); #endif - // imp::horrible_cast(0ll); +#if LIBIMP_ENDIAN_LIT + EXPECT_EQ(imp::horrible_cast(0xff00'0000'0001ll), 1); +#else + EXPECT_EQ(imp::horrible_cast(0xff00'0000'0001ll), 0xff00); +#endif } #if defined(LIBIMP_CPP_17)