mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Upgrade to C++20 (#4239)
* Use explicit this capture required by C++20 * Use C++20 span * Replace wpi::numbers with std::numbers * Fix C++20 clang-tidy warning false positive in fmt * Remove ciso646 include since C++20 removed that header * Fix global-buffer-overflow asan warnings in ntcore tests * Add DIOSetProxy constructor to HAL * Upgrade MSVC compiler to 2022 * Bump native-utils to 2023.2.7 (changes to std=c++20) Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
This commit is contained in:
@@ -254,7 +254,7 @@ Storage::Value& Storage::GetValue(std::string_view key) {
|
||||
} \
|
||||
\
|
||||
std::vector<ArrCType>& Storage::Get##CapsName##Array( \
|
||||
std::string_view key, wpi::span<const ArrCType> defaultVal) { \
|
||||
std::string_view key, std::span<const ArrCType> defaultVal) { \
|
||||
auto& valuePtr = m_values[key]; \
|
||||
bool setValue = false; \
|
||||
if (!valuePtr) { \
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <wpi/numbers>
|
||||
#include <numbers>
|
||||
|
||||
#include "glass/Context.h"
|
||||
#include "glass/DataSource.h"
|
||||
@@ -54,7 +54,7 @@ void glass::DisplayGyro(GyroModel* m) {
|
||||
|
||||
// Draw the spokes at every 5 degrees and a "major" spoke every 45 degrees.
|
||||
for (int i = -175; i <= 180; i += 5) {
|
||||
double radians = i * 2 * wpi::numbers::pi / 360.0;
|
||||
double radians = i * 2 * std::numbers::pi / 360.0;
|
||||
ImVec2 direction(std::sin(radians), -std::cos(radians));
|
||||
|
||||
bool major = i % 45 == 0;
|
||||
@@ -74,7 +74,7 @@ void glass::DisplayGyro(GyroModel* m) {
|
||||
|
||||
draw->AddCircleFilled(center, radius * 0.075, secondaryColor, 50);
|
||||
|
||||
double radians = value * 2 * wpi::numbers::pi / 360.0;
|
||||
double radians = value * 2 * std::numbers::pi / 360.0;
|
||||
draw->AddLine(
|
||||
center - ImVec2(1, 0),
|
||||
center + ImVec2(std::sin(radians), -std::cos(radians)) * radius * 0.95f,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <imgui.h>
|
||||
#include <imgui_internal.h>
|
||||
#include <wpi/numbers>
|
||||
#include <numbers>
|
||||
|
||||
#include "glass/Context.h"
|
||||
#include "glass/DataSource.h"
|
||||
@@ -55,11 +55,11 @@ void glass::DisplayDrive(DriveModel* m) {
|
||||
draw->AddTriangleFilled(
|
||||
arrowPos,
|
||||
arrowPos + ImRotate(ImVec2(0.0f, 7.5f),
|
||||
std::cos(angle + wpi::numbers::pi / 4),
|
||||
std::sin(angle + wpi::numbers::pi / 4)),
|
||||
std::cos(angle + std::numbers::pi / 4),
|
||||
std::sin(angle + std::numbers::pi / 4)),
|
||||
arrowPos + ImRotate(ImVec2(0.0f, 7.5f),
|
||||
std::cos(angle - wpi::numbers::pi / 4),
|
||||
std::sin(angle - wpi::numbers::pi / 4)),
|
||||
std::cos(angle - std::numbers::pi / 4),
|
||||
std::sin(angle - std::numbers::pi / 4)),
|
||||
color);
|
||||
};
|
||||
|
||||
@@ -88,30 +88,30 @@ void glass::DisplayDrive(DriveModel* m) {
|
||||
if (rotation != 0) {
|
||||
float radius = 60.0f;
|
||||
double a1 = 0.0;
|
||||
double a2 = wpi::numbers::pi / 2 * rotation;
|
||||
double a2 = std::numbers::pi / 2 * rotation;
|
||||
|
||||
// PathArcTo requires a_min <= a_max, and rotation can be negative
|
||||
if (a1 > a2) {
|
||||
draw->PathArcTo(center, radius, a2, a1, 20);
|
||||
draw->PathStroke(color, false);
|
||||
draw->PathArcTo(center, radius, a2 + wpi::numbers::pi,
|
||||
a1 + wpi::numbers::pi, 20);
|
||||
draw->PathArcTo(center, radius, a2 + std::numbers::pi,
|
||||
a1 + std::numbers::pi, 20);
|
||||
draw->PathStroke(color, false);
|
||||
} else {
|
||||
draw->PathArcTo(center, radius, a1, a2, 20);
|
||||
draw->PathStroke(color, false);
|
||||
draw->PathArcTo(center, radius, a1 + wpi::numbers::pi,
|
||||
a2 + wpi::numbers::pi, 20);
|
||||
draw->PathArcTo(center, radius, a1 + std::numbers::pi,
|
||||
a2 + std::numbers::pi, 20);
|
||||
draw->PathStroke(color, false);
|
||||
}
|
||||
|
||||
double adder = rotation < 0 ? wpi::numbers::pi : 0;
|
||||
double adder = rotation < 0 ? std::numbers::pi : 0;
|
||||
|
||||
auto arrowPos =
|
||||
center + ImVec2(radius * -std::cos(a2), radius * -std::sin(a2));
|
||||
drawArrow(arrowPos, a2 + adder);
|
||||
|
||||
a2 += wpi::numbers::pi;
|
||||
a2 += std::numbers::pi;
|
||||
arrowPos = center + ImVec2(radius * -std::cos(a2), radius * -std::sin(a2));
|
||||
drawArrow(arrowPos, a2 + adder);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ class PopupState {
|
||||
|
||||
SelectedTargetInfo* GetTarget() { return &m_target; }
|
||||
FieldObjectModel* GetInsertModel() { return m_insertModel; }
|
||||
wpi::span<const frc::Pose2d> GetInsertPoses() const { return m_insertPoses; }
|
||||
std::span<const frc::Pose2d> GetInsertPoses() const { return m_insertPoses; }
|
||||
|
||||
void Display(Field2DModel* model, const FieldFrameData& ffd);
|
||||
|
||||
@@ -189,7 +189,7 @@ class ObjectInfo {
|
||||
|
||||
DisplayOptions GetDisplayOptions() const;
|
||||
void DisplaySettings();
|
||||
void DrawLine(ImDrawList* drawList, wpi::span<const ImVec2> points) const;
|
||||
void DrawLine(ImDrawList* drawList, std::span<const ImVec2> points) const;
|
||||
|
||||
void LoadImage();
|
||||
const gui::Texture& GetTexture() const { return m_texture; }
|
||||
@@ -617,7 +617,7 @@ void ObjectInfo::DisplaySettings() {
|
||||
}
|
||||
|
||||
void ObjectInfo::DrawLine(ImDrawList* drawList,
|
||||
wpi::span<const ImVec2> points) const {
|
||||
std::span<const ImVec2> points) const {
|
||||
if (points.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user