Use std::bit_cast (#7492)

This commit is contained in:
Tyler Veness
2024-12-07 23:02:09 -08:00
committed by GitHub
parent 4910436b10
commit ae44295024
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),