Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions libredex/StlUtil.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#pragma once

#include <algorithm>
#include <cstring>
#include <deque>
#include <vector>

Expand Down Expand Up @@ -45,9 +46,11 @@ size_t erase_if(Container& c, const Pred& pred) {
return removed;
}

template <typename To, typename From>
constexpr To bit_cast(const From& from) noexcept {
return __builtin_bit_cast(To, from);
template <class To, class From>
constexpr To bit_cast(const From& src) noexcept {
To dst;
std::memcpy(&dst, &src, sizeof(To));
return dst;
}

} // namespace std20