Skip to content

Commit 5db12ec

Browse files
[libc] Make UInt<T> trivially copyable
This patch defaults the copy constructor and copy operator so it can be used with __builtin_bit_cast Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D148794
1 parent 3310da0 commit 5db12ec

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

libc/src/__support/UInt.h

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,9 @@ template <size_t Bits> struct UInt {
3535
static constexpr uint64_t low(uint64_t v) { return v & MASK32; }
3636
static constexpr uint64_t high(uint64_t v) { return (v >> 32) & MASK32; }
3737

38-
constexpr UInt() {}
38+
constexpr UInt() = default;
3939

40-
constexpr UInt(const UInt<Bits> &other) {
41-
for (size_t i = 0; i < WORDCOUNT; ++i)
42-
val[i] = other.val[i];
43-
}
40+
constexpr UInt(const UInt<Bits> &other) = default;
4441

4542
template <size_t OtherBits> constexpr UInt(const UInt<OtherBits> &other) {
4643
if (OtherBits >= Bits) {
@@ -90,11 +87,7 @@ template <size_t Bits> struct UInt {
9087
return uint8_t(uint64_t(*this));
9188
}
9289

93-
UInt<Bits> &operator=(const UInt<Bits> &other) {
94-
for (size_t i = 0; i < WORDCOUNT; ++i)
95-
val[i] = other.val[i];
96-
return *this;
97-
}
90+
UInt<Bits> &operator=(const UInt<Bits> &other) = default;
9891

9992
constexpr bool is_zero() const {
10093
for (size_t i = 0; i < WORDCOUNT; ++i) {

0 commit comments

Comments
 (0)