Skip to content

Commit f9f11bd

Browse files
committed
test fix
1 parent 1790677 commit f9f11bd

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

libredex/StlUtil.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#pragma once
99

1010
#include <algorithm>
11+
#include <cstring>
1112
#include <deque>
1213
#include <vector>
1314

@@ -45,9 +46,15 @@ size_t erase_if(Container& c, const Pred& pred) {
4546
return removed;
4647
}
4748

48-
template <typename To, typename From>
49-
constexpr To bit_cast(const From& from) noexcept {
50-
return __builtin_bit_cast(To, from);
49+
template <class To, class From>
50+
constexpr To bit_cast(const From& src) noexcept {
51+
static_assert(std::is_trivially_constructible_v<To>,
52+
"This implementation additionally requires "
53+
"destination type to be trivially constructible");
54+
55+
To dst;
56+
std::memcpy(&dst, &src, sizeof(To));
57+
return dst;
5158
}
5259

5360
} // namespace std20

0 commit comments

Comments
 (0)