mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Use std::bit_cast (#7492)
This commit is contained in:
@@ -377,7 +377,7 @@ void DataLog::AppendFloat(int entry, float value, int64_t timestamp) {
|
||||
if constexpr (std::endian::native == std::endian::little) {
|
||||
std::memcpy(buf, &value, 4);
|
||||
} else {
|
||||
wpi::support::endian::write32le(buf, wpi::bit_cast<uint32_t>(value));
|
||||
wpi::support::endian::write32le(buf, std::bit_cast<uint32_t>(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ void DataLog::AppendDouble(int entry, double value, int64_t timestamp) {
|
||||
if constexpr (std::endian::native == std::endian::little) {
|
||||
std::memcpy(buf, &value, 8);
|
||||
} else {
|
||||
wpi::support::endian::write64le(buf, wpi::bit_cast<uint64_t>(value));
|
||||
wpi::support::endian::write64le(buf, std::bit_cast<uint64_t>(value));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -508,14 +508,14 @@ void DataLog::AppendFloatArray(int entry, std::span<const float> arr,
|
||||
while ((arr.size() * 4) > kBlockSize) {
|
||||
buf = Reserve(kBlockSize);
|
||||
for (auto val : arr.subspan(0, kBlockSize / 4)) {
|
||||
wpi::support::endian::write32le(buf, wpi::bit_cast<uint32_t>(val));
|
||||
wpi::support::endian::write32le(buf, std::bit_cast<uint32_t>(val));
|
||||
buf += 4;
|
||||
}
|
||||
arr = arr.subspan(kBlockSize / 4);
|
||||
}
|
||||
buf = Reserve(arr.size() * 4);
|
||||
for (auto val : arr) {
|
||||
wpi::support::endian::write32le(buf, wpi::bit_cast<uint32_t>(val));
|
||||
wpi::support::endian::write32le(buf, std::bit_cast<uint32_t>(val));
|
||||
buf += 4;
|
||||
}
|
||||
}
|
||||
@@ -540,14 +540,14 @@ void DataLog::AppendDoubleArray(int entry, std::span<const double> arr,
|
||||
while ((arr.size() * 8) > kBlockSize) {
|
||||
buf = Reserve(kBlockSize);
|
||||
for (auto val : arr.subspan(0, kBlockSize / 8)) {
|
||||
wpi::support::endian::write64le(buf, wpi::bit_cast<uint64_t>(val));
|
||||
wpi::support::endian::write64le(buf, std::bit_cast<uint64_t>(val));
|
||||
buf += 8;
|
||||
}
|
||||
arr = arr.subspan(kBlockSize / 8);
|
||||
}
|
||||
buf = Reserve(arr.size() * 8);
|
||||
for (auto val : arr) {
|
||||
wpi::support::endian::write64le(buf, wpi::bit_cast<uint64_t>(val));
|
||||
wpi::support::endian::write64le(buf, std::bit_cast<uint64_t>(val));
|
||||
buf += 8;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user