mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +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:
@@ -9,6 +9,7 @@
|
||||
#include <cstring>
|
||||
#include <initializer_list>
|
||||
#include <memory>
|
||||
#include <span>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
@@ -25,7 +26,6 @@
|
||||
#include <wpi/StringExtras.h>
|
||||
#include <wpi/mpack.h>
|
||||
#include <wpi/raw_ostream.h>
|
||||
#include <wpi/span.h>
|
||||
|
||||
#include "glass/Context.h"
|
||||
#include "glass/DataSource.h"
|
||||
@@ -58,7 +58,7 @@ static bool IsVisible(ShowCategory category, bool persistent, bool retained) {
|
||||
}
|
||||
}
|
||||
|
||||
static std::string BooleanArrayToString(wpi::span<const int> in) {
|
||||
static std::string BooleanArrayToString(std::span<const int> in) {
|
||||
std::string rv;
|
||||
wpi::raw_string_ostream os{rv};
|
||||
os << '[';
|
||||
@@ -78,17 +78,17 @@ static std::string BooleanArrayToString(wpi::span<const int> in) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
static std::string IntegerArrayToString(wpi::span<const int64_t> in) {
|
||||
static std::string IntegerArrayToString(std::span<const int64_t> in) {
|
||||
return fmt::format("[{:d}]", fmt::join(in, ","));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static std::string FloatArrayToString(wpi::span<const T> in) {
|
||||
static std::string FloatArrayToString(std::span<const T> in) {
|
||||
static_assert(std::is_same_v<T, float> || std::is_same_v<T, double>);
|
||||
return fmt::format("[{:.6f}]", fmt::join(in, ","));
|
||||
}
|
||||
|
||||
static std::string StringArrayToString(wpi::span<const std::string> in) {
|
||||
static std::string StringArrayToString(std::span<const std::string> in) {
|
||||
std::string rv;
|
||||
wpi::raw_string_ostream os{rv};
|
||||
os << '[';
|
||||
@@ -528,7 +528,7 @@ void NetworkTablesModel::RebuildTreeImpl(std::vector<TreeNode>* tree,
|
||||
|
||||
// get to leaf
|
||||
auto nodes = tree;
|
||||
for (auto part : wpi::drop_back(wpi::span{parts.begin(), parts.end()})) {
|
||||
for (auto part : wpi::drop_back(std::span{parts.begin(), parts.end()})) {
|
||||
auto it =
|
||||
std::find_if(nodes->begin(), nodes->end(),
|
||||
[&](const auto& node) { return node.name == part; });
|
||||
@@ -584,7 +584,7 @@ NetworkTablesModel::Entry* NetworkTablesModel::AddEntry(NT_Topic topic) {
|
||||
}
|
||||
|
||||
void NetworkTablesModel::Client::UpdatePublishers(
|
||||
wpi::span<const uint8_t> data) {
|
||||
std::span<const uint8_t> data) {
|
||||
mpack_reader_t r;
|
||||
mpack_reader_init_data(&r, data);
|
||||
uint32_t numPub = mpack_expect_array_max(&r, 1000);
|
||||
@@ -639,7 +639,7 @@ static void DecodeSubscriberOptions(
|
||||
}
|
||||
|
||||
void NetworkTablesModel::Client::UpdateSubscribers(
|
||||
wpi::span<const uint8_t> data) {
|
||||
std::span<const uint8_t> data) {
|
||||
mpack_reader_t r;
|
||||
mpack_reader_init_data(&r, data);
|
||||
uint32_t numSub = mpack_expect_array_max(&r, 1000);
|
||||
@@ -681,7 +681,7 @@ void NetworkTablesModel::Client::UpdateSubscribers(
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkTablesModel::UpdateClients(wpi::span<const uint8_t> data) {
|
||||
void NetworkTablesModel::UpdateClients(std::span<const uint8_t> data) {
|
||||
mpack_reader_t r;
|
||||
mpack_reader_init_data(&r, data);
|
||||
uint32_t numClients = mpack_expect_array_max(&r, 100);
|
||||
|
||||
Reference in New Issue
Block a user