Use std::bit_cast (#7567)

Backport #7492

Co-authored-by: Tyler Veness <calcmogul@gmail.com>
This commit is contained in:
Ryan Blue
2024-12-22 16:34:16 -05:00
committed by GitHub
parent d631fa8e4b
commit 0c99073b94
7 changed files with 33 additions and 34 deletions

View File

@@ -2,15 +2,14 @@
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <bit>
#include <cstdio>
#include <memory>
#include <string>
#include <fmt/format.h>
#include <wpi/MathExtras.h>
#include <wpi/SmallVector.h>
#include <wpi/StringExtras.h>
#include <wpi/bit.h>
#include <wpi/print.h>
#include <wpi/timestamp.h>
@@ -43,7 +42,7 @@ static bool NewlineBuffer(std::string& rem, uv::Buffer& buf, size_t len,
if (tcp) {
// Header is 2 byte len, 1 byte type, 4 byte timestamp, 2 byte sequence num
uint32_t ts =
wpi::bit_cast<uint32_t, float>((wpi::Now() - startTime) * 1.0e-6);
std::bit_cast<uint32_t, float>((wpi::Now() - startTime) * 1.0e-6);
uint16_t len = rem.size() + toCopy.size() + 1 + 4 + 2;
const uint8_t header[] = {static_cast<uint8_t>((len >> 8) & 0xff),
static_cast<uint8_t>(len & 0xff),