Skip to content

Commit

Permalink
test fix
Browse files Browse the repository at this point in the history
  • Loading branch information
roro47 committed Jun 27, 2024
1 parent 1790677 commit f9f11bd
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 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,15 @@ 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 {
static_assert(std::is_trivially_constructible_v<To>,
"This implementation additionally requires "
"destination type to be trivially constructible");

To dst;
std::memcpy(&dst, &src, sizeof(To));
return dst;
}

} // namespace std20

0 comments on commit f9f11bd

Please sign in to comment.