mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01: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:
@@ -42,7 +42,7 @@ Pose2d FieldObject2d::GetPose() const {
|
||||
return m_poses[0];
|
||||
}
|
||||
|
||||
void FieldObject2d::SetPoses(wpi::span<const Pose2d> poses) {
|
||||
void FieldObject2d::SetPoses(std::span<const Pose2d> poses) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_poses.assign(poses.begin(), poses.end());
|
||||
UpdateEntry();
|
||||
@@ -68,7 +68,7 @@ std::vector<Pose2d> FieldObject2d::GetPoses() const {
|
||||
return std::vector<Pose2d>(m_poses.begin(), m_poses.end());
|
||||
}
|
||||
|
||||
wpi::span<const Pose2d> FieldObject2d::GetPoses(
|
||||
std::span<const Pose2d> FieldObject2d::GetPoses(
|
||||
wpi::SmallVectorImpl<Pose2d>& out) const {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
UpdateFromEntry();
|
||||
|
||||
@@ -176,35 +176,35 @@ void SendableBuilderImpl::AddStringProperty(
|
||||
|
||||
void SendableBuilderImpl::AddBooleanArrayProperty(
|
||||
std::string_view key, std::function<std::vector<int>()> getter,
|
||||
std::function<void(wpi::span<const int>)> setter) {
|
||||
std::function<void(std::span<const int>)> setter) {
|
||||
AddPropertyImpl(m_table->GetBooleanArrayTopic(key), std::move(getter),
|
||||
std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddIntegerArrayProperty(
|
||||
std::string_view key, std::function<std::vector<int64_t>()> getter,
|
||||
std::function<void(wpi::span<const int64_t>)> setter) {
|
||||
std::function<void(std::span<const int64_t>)> setter) {
|
||||
AddPropertyImpl(m_table->GetIntegerArrayTopic(key), std::move(getter),
|
||||
std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddFloatArrayProperty(
|
||||
std::string_view key, std::function<std::vector<float>()> getter,
|
||||
std::function<void(wpi::span<const float>)> setter) {
|
||||
std::function<void(std::span<const float>)> setter) {
|
||||
AddPropertyImpl(m_table->GetFloatArrayTopic(key), std::move(getter),
|
||||
std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddDoubleArrayProperty(
|
||||
std::string_view key, std::function<std::vector<double>()> getter,
|
||||
std::function<void(wpi::span<const double>)> setter) {
|
||||
std::function<void(std::span<const double>)> setter) {
|
||||
AddPropertyImpl(m_table->GetDoubleArrayTopic(key), std::move(getter),
|
||||
std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddStringArrayProperty(
|
||||
std::string_view key, std::function<std::vector<std::string>()> getter,
|
||||
std::function<void(wpi::span<const std::string>)> setter) {
|
||||
std::function<void(std::span<const std::string>)> setter) {
|
||||
AddPropertyImpl(m_table->GetStringArrayTopic(key), std::move(getter),
|
||||
std::move(setter));
|
||||
}
|
||||
@@ -212,7 +212,7 @@ void SendableBuilderImpl::AddStringArrayProperty(
|
||||
void SendableBuilderImpl::AddRawProperty(
|
||||
std::string_view key, std::string_view typeString,
|
||||
std::function<std::vector<uint8_t>()> getter,
|
||||
std::function<void(wpi::span<const uint8_t>)> setter) {
|
||||
std::function<void(std::span<const uint8_t>)> setter) {
|
||||
auto topic = m_table->GetRawTopic(key);
|
||||
auto prop = std::make_unique<PropertyImpl<nt::RawTopic>>();
|
||||
if (getter) {
|
||||
@@ -265,35 +265,35 @@ void SendableBuilderImpl::AddSmallStringProperty(
|
||||
|
||||
void SendableBuilderImpl::AddSmallBooleanArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const int>(wpi::SmallVectorImpl<int>& buf)> getter,
|
||||
std::function<void(wpi::span<const int>)> setter) {
|
||||
std::function<std::span<const int>(wpi::SmallVectorImpl<int>& buf)> getter,
|
||||
std::function<void(std::span<const int>)> setter) {
|
||||
AddSmallPropertyImpl<int, 16>(m_table->GetBooleanArrayTopic(key),
|
||||
std::move(getter), std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddSmallIntegerArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const int64_t>(wpi::SmallVectorImpl<int64_t>& buf)>
|
||||
std::function<std::span<const int64_t>(wpi::SmallVectorImpl<int64_t>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const int64_t>)> setter) {
|
||||
std::function<void(std::span<const int64_t>)> setter) {
|
||||
AddSmallPropertyImpl<int64_t, 16>(m_table->GetIntegerArrayTopic(key),
|
||||
std::move(getter), std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddSmallFloatArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const float>(wpi::SmallVectorImpl<float>& buf)>
|
||||
std::function<std::span<const float>(wpi::SmallVectorImpl<float>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const float>)> setter) {
|
||||
std::function<void(std::span<const float>)> setter) {
|
||||
AddSmallPropertyImpl<float, 16>(m_table->GetFloatArrayTopic(key),
|
||||
std::move(getter), std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddSmallDoubleArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<wpi::span<const double>(wpi::SmallVectorImpl<double>& buf)>
|
||||
std::function<std::span<const double>(wpi::SmallVectorImpl<double>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const double>)> setter) {
|
||||
std::function<void(std::span<const double>)> setter) {
|
||||
AddSmallPropertyImpl<double, 16>(m_table->GetDoubleArrayTopic(key),
|
||||
std::move(getter), std::move(setter));
|
||||
}
|
||||
@@ -301,18 +301,18 @@ void SendableBuilderImpl::AddSmallDoubleArrayProperty(
|
||||
void SendableBuilderImpl::AddSmallStringArrayProperty(
|
||||
std::string_view key,
|
||||
std::function<
|
||||
wpi::span<const std::string>(wpi::SmallVectorImpl<std::string>& buf)>
|
||||
std::span<const std::string>(wpi::SmallVectorImpl<std::string>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const std::string>)> setter) {
|
||||
std::function<void(std::span<const std::string>)> setter) {
|
||||
AddSmallPropertyImpl<std::string, 16>(m_table->GetStringArrayTopic(key),
|
||||
std::move(getter), std::move(setter));
|
||||
}
|
||||
|
||||
void SendableBuilderImpl::AddSmallRawProperty(
|
||||
std::string_view key, std::string_view typeString,
|
||||
std::function<wpi::span<uint8_t>(wpi::SmallVectorImpl<uint8_t>& buf)>
|
||||
std::function<std::span<uint8_t>(wpi::SmallVectorImpl<uint8_t>& buf)>
|
||||
getter,
|
||||
std::function<void(wpi::span<const uint8_t>)> setter) {
|
||||
std::function<void(std::span<const uint8_t>)> setter) {
|
||||
auto topic = m_table->GetRawTopic(key);
|
||||
auto prop = std::make_unique<PropertyImpl<nt::RawTopic>>();
|
||||
if (getter) {
|
||||
|
||||
@@ -157,63 +157,63 @@ std::string SmartDashboard::GetString(std::string_view keyName,
|
||||
}
|
||||
|
||||
bool SmartDashboard::PutBooleanArray(std::string_view key,
|
||||
wpi::span<const int> value) {
|
||||
std::span<const int> value) {
|
||||
return GetInstance().table->GetEntry(key).SetBooleanArray(value);
|
||||
}
|
||||
|
||||
bool SmartDashboard::SetDefaultBooleanArray(std::string_view key,
|
||||
wpi::span<const int> defaultValue) {
|
||||
std::span<const int> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).SetDefaultBooleanArray(
|
||||
defaultValue);
|
||||
}
|
||||
|
||||
std::vector<int> SmartDashboard::GetBooleanArray(
|
||||
std::string_view key, wpi::span<const int> defaultValue) {
|
||||
std::string_view key, std::span<const int> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).GetBooleanArray(defaultValue);
|
||||
}
|
||||
|
||||
bool SmartDashboard::PutNumberArray(std::string_view key,
|
||||
wpi::span<const double> value) {
|
||||
std::span<const double> value) {
|
||||
return GetInstance().table->GetEntry(key).SetDoubleArray(value);
|
||||
}
|
||||
|
||||
bool SmartDashboard::SetDefaultNumberArray(
|
||||
std::string_view key, wpi::span<const double> defaultValue) {
|
||||
std::string_view key, std::span<const double> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).SetDefaultDoubleArray(defaultValue);
|
||||
}
|
||||
|
||||
std::vector<double> SmartDashboard::GetNumberArray(
|
||||
std::string_view key, wpi::span<const double> defaultValue) {
|
||||
std::string_view key, std::span<const double> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).GetDoubleArray(defaultValue);
|
||||
}
|
||||
|
||||
bool SmartDashboard::PutStringArray(std::string_view key,
|
||||
wpi::span<const std::string> value) {
|
||||
std::span<const std::string> value) {
|
||||
return GetInstance().table->GetEntry(key).SetStringArray(value);
|
||||
}
|
||||
|
||||
bool SmartDashboard::SetDefaultStringArray(
|
||||
std::string_view key, wpi::span<const std::string> defaultValue) {
|
||||
std::string_view key, std::span<const std::string> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).SetDefaultStringArray(defaultValue);
|
||||
}
|
||||
|
||||
std::vector<std::string> SmartDashboard::GetStringArray(
|
||||
std::string_view key, wpi::span<const std::string> defaultValue) {
|
||||
std::string_view key, std::span<const std::string> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).GetStringArray(defaultValue);
|
||||
}
|
||||
|
||||
bool SmartDashboard::PutRaw(std::string_view key,
|
||||
wpi::span<const uint8_t> value) {
|
||||
std::span<const uint8_t> value) {
|
||||
return GetInstance().table->GetEntry(key).SetRaw(value);
|
||||
}
|
||||
|
||||
bool SmartDashboard::SetDefaultRaw(std::string_view key,
|
||||
wpi::span<const uint8_t> defaultValue) {
|
||||
std::span<const uint8_t> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).SetDefaultRaw(defaultValue);
|
||||
}
|
||||
|
||||
std::vector<uint8_t> SmartDashboard::GetRaw(
|
||||
std::string_view key, wpi::span<const uint8_t> defaultValue) {
|
||||
std::string_view key, std::span<const uint8_t> defaultValue) {
|
||||
return GetInstance().table->GetEntry(key).GetRaw(defaultValue);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user