[libc-commits] [libc] 5db12ec - [libc] Make UInt<T> trivially copyable
Mikhail R. Gadelha via libc-commits
libc-commits at lists.llvm.org
Thu Apr 20 09:01:31 PDT 2023
Author: Mikhail R. Gadelha
Date: 2023-04-20T13:01:19-03:00
New Revision: 5db12eca1f70bb9c2dab33ff88dcccdfba75af6e
URL: https://github.com/llvm/llvm-project/commit/5db12eca1f70bb9c2dab33ff88dcccdfba75af6e
DIFF: https://github.com/llvm/llvm-project/commit/5db12eca1f70bb9c2dab33ff88dcccdfba75af6e.diff
LOG: [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
Added:
Modified:
libc/src/__support/UInt.h
Removed:
################################################################################
diff --git a/libc/src/__support/UInt.h b/libc/src/__support/UInt.h
index 2cbd3dfea6fb8..c151689c3bbb9 100644
--- a/libc/src/__support/UInt.h
+++ b/libc/src/__support/UInt.h
@@ -35,12 +35,9 @@ template <size_t Bits> struct UInt {
static constexpr uint64_t low(uint64_t v) { return v & MASK32; }
static constexpr uint64_t high(uint64_t v) { return (v >> 32) & MASK32; }
- constexpr UInt() {}
+ constexpr UInt() = default;
- constexpr UInt(const UInt<Bits> &other) {
- for (size_t i = 0; i < WORDCOUNT; ++i)
- val[i] = other.val[i];
- }
+ constexpr UInt(const UInt<Bits> &other) = default;
template <size_t OtherBits> constexpr UInt(const UInt<OtherBits> &other) {
if (OtherBits >= Bits) {
@@ -90,11 +87,7 @@ template <size_t Bits> struct UInt {
return uint8_t(uint64_t(*this));
}
- UInt<Bits> &operator=(const UInt<Bits> &other) {
- for (size_t i = 0; i < WORDCOUNT; ++i)
- val[i] = other.val[i];
- return *this;
- }
+ UInt<Bits> &operator=(const UInt<Bits> &other) = default;
constexpr bool is_zero() const {
for (size_t i = 0; i < WORDCOUNT; ++i) {
More information about the libc-commits
mailing list