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:
Tyler Veness
2022-10-15 16:33:14 -07:00
committed by GitHub
parent 396143004c
commit fbdc810887
355 changed files with 1659 additions and 2918 deletions

View File

@@ -6,6 +6,7 @@
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
@@ -25,7 +26,6 @@ using CS_Source = CS_Handle; // NOLINT
#include <networktables/StringArrayTopic.h>
#include <wpi/sendable/Sendable.h>
#include <wpi/sendable/SendableHelper.h>
#include <wpi/span.h>
namespace frc {
@@ -64,7 +64,7 @@ class SendableCameraWrapper
* @param cameraUrls camera URLs
*/
SendableCameraWrapper(std::string_view cameraName,
wpi::span<const std::string> cameraUrls,
std::span<const std::string> cameraUrls,
const private_init&);
/**
@@ -79,7 +79,7 @@ class SendableCameraWrapper
static SendableCameraWrapper& Wrap(CS_Source source);
static SendableCameraWrapper& Wrap(std::string_view cameraName,
wpi::span<const std::string> cameraUrls);
std::span<const std::string> cameraUrls);
void InitSendable(wpi::SendableBuilder& builder) override;
@@ -97,7 +97,7 @@ inline SendableCameraWrapper::SendableCameraWrapper(std::string_view name,
}
inline SendableCameraWrapper::SendableCameraWrapper(
std::string_view cameraName, wpi::span<const std::string> cameraUrls,
std::string_view cameraName, std::span<const std::string> cameraUrls,
const private_init&)
: SendableCameraWrapper(cameraName, private_init{}) {
m_streams = nt::NetworkTableInstance::GetDefault()
@@ -123,7 +123,7 @@ inline SendableCameraWrapper& SendableCameraWrapper::Wrap(CS_Source source) {
}
inline SendableCameraWrapper& SendableCameraWrapper::Wrap(
std::string_view cameraName, wpi::span<const std::string> cameraUrls) {
std::string_view cameraName, std::span<const std::string> cameraUrls) {
auto& wrapper = detail::GetSendableCameraWrapper(cameraName);
if (!wrapper) {
wrapper = std::make_shared<SendableCameraWrapper>(cameraName, cameraUrls,

View File

@@ -6,6 +6,7 @@
#include <functional>
#include <memory>
#include <span>
#include <string>
#include <string_view>
#include <vector>
@@ -14,7 +15,6 @@
#include <networktables/NetworkTableValue.h>
#include <wpi/SmallSet.h>
#include <wpi/StringMap.h>
#include <wpi/span.h>
#include "frc/shuffleboard/BuiltInLayouts.h"
#include "frc/shuffleboard/LayoutType.h"
@@ -137,7 +137,7 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
* @return a widget to display the camera stream
*/
ComplexWidget& AddCamera(std::string_view title, std::string_view cameraName,
wpi::span<const std::string> cameraUrls);
std::span<const std::string> cameraUrls);
/**
* Adds a widget to this container to display the given sendable.
@@ -259,10 +259,10 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
* @return a widget to display the sendable data
* @throws IllegalArgumentException if a widget already exists in this
* container with the given title
* @see AddPersistent(std::string_view, wpi::span<const bool>)
* Add(std::string_view title, wpi::span<const bool> defaultValue)
* @see AddPersistent(std::string_view, std::span<const bool>)
* Add(std::string_view title, std::span<const bool> defaultValue)
*/
SimpleWidget& Add(std::string_view title, wpi::span<const bool> defaultValue);
SimpleWidget& Add(std::string_view title, std::span<const bool> defaultValue);
/**
* Adds a widget to this container to display the given data.
@@ -272,11 +272,11 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
* @return a widget to display the sendable data
* @throws IllegalArgumentException if a widget already exists in this
* container with the given title
* @see AddPersistent(std::string_view, wpi::span<const double>)
* Add(std::string_view title, wpi::span<const double> defaultValue)
* @see AddPersistent(std::string_view, std::span<const double>)
* Add(std::string_view title, std::span<const double> defaultValue)
*/
SimpleWidget& Add(std::string_view title,
wpi::span<const double> defaultValue);
std::span<const double> defaultValue);
/**
* Adds a widget to this container to display the given data.
@@ -286,11 +286,11 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
* @return a widget to display the sendable data
* @throws IllegalArgumentException if a widget already exists in this
* container with the given title
* @see AddPersistent(std::string_view, wpi::span<const double>)
* Add(std::string_view title, wpi::span<const double> defaultValue)
* @see AddPersistent(std::string_view, std::span<const double>)
* Add(std::string_view title, std::span<const double> defaultValue)
*/
SimpleWidget& Add(std::string_view title,
wpi::span<const float> defaultValue);
std::span<const float> defaultValue);
/**
* Adds a widget to this container to display the given data.
@@ -300,11 +300,11 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
* @return a widget to display the sendable data
* @throws IllegalArgumentException if a widget already exists in this
* container with the given title
* @see AddPersistent(std::string_view, wpi::span<const double>)
* Add(std::string_view title, wpi::span<const double> defaultValue)
* @see AddPersistent(std::string_view, std::span<const double>)
* Add(std::string_view title, std::span<const double> defaultValue)
*/
SimpleWidget& Add(std::string_view title,
wpi::span<const int64_t> defaultValue);
std::span<const int64_t> defaultValue);
/**
* Adds a widget to this container to display the given data.
@@ -314,11 +314,11 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
* @return a widget to display the sendable data
* @throws IllegalArgumentException if a widget already exists in this
* container with the given title
* @see AddPersistent(std::string_view, wpi::span<const std::string>)
* Add(std::string_view title, wpi::span<const std::string> defaultValue)
* @see AddPersistent(std::string_view, std::span<const std::string>)
* Add(std::string_view title, std::span<const std::string> defaultValue)
*/
SimpleWidget& Add(std::string_view title,
wpi::span<const std::string> defaultValue);
std::span<const std::string> defaultValue);
/**
* Adds a widget to this container. The widget will display the data provided
@@ -600,82 +600,82 @@ class ShuffleboardContainer : public virtual ShuffleboardValue {
/**
* Adds a widget to this container to display a simple piece of data.
*
* Unlike Add(std::string_view, wpi::span<const bool>), the value in the
* Unlike Add(std::string_view, std::span<const bool>), the value in the
* widget will be saved on the robot and will be used when the robot program
* next starts rather than {@code defaultValue}.
*
* @param title the title of the widget
* @param defaultValue the default value of the widget
* @return a widget to display the sendable data
* @see Add(std::string_view, wpi::span<const bool>)
* Add(std::string_view title, wpi::span<const bool> defaultValue)
* @see Add(std::string_view, std::span<const bool>)
* Add(std::string_view title, std::span<const bool> defaultValue)
*/
SimpleWidget& AddPersistent(std::string_view title,
wpi::span<const bool> defaultValue);
std::span<const bool> defaultValue);
/**
* Adds a widget to this container to display a simple piece of data.
*
* Unlike Add(std::string_view, wpi::span<const double>), the value in the
* Unlike Add(std::string_view, std::span<const double>), the value in the
* widget will be saved on the robot and will be used when the robot program
* next starts rather than {@code defaultValue}.
*
* @param title the title of the widget
* @param defaultValue the default value of the widget
* @return a widget to display the sendable data
* @see Add(std::string_view, wpi::span<const double>)
* Add(std::string_view title, wpi::span<const double> defaultValue)
* @see Add(std::string_view, std::span<const double>)
* Add(std::string_view title, std::span<const double> defaultValue)
*/
SimpleWidget& AddPersistent(std::string_view title,
wpi::span<const double> defaultValue);
std::span<const double> defaultValue);
/**
* Adds a widget to this container to display a simple piece of data.
*
* Unlike Add(std::string_view, wpi::span<const float>), the value in the
* Unlike Add(std::string_view, std::span<const float>), the value in the
* widget will be saved on the robot and will be used when the robot program
* next starts rather than {@code defaultValue}.
*
* @param title the title of the widget
* @param defaultValue the default value of the widget
* @return a widget to display the sendable data
* @see Add(std::string_view, wpi::span<const float>)
* Add(std::string_view title, wpi::span<const float> defaultValue)
* @see Add(std::string_view, std::span<const float>)
* Add(std::string_view title, std::span<const float> defaultValue)
*/
SimpleWidget& AddPersistent(std::string_view title,
wpi::span<const float> defaultValue);
std::span<const float> defaultValue);
/**
* Adds a widget to this container to display a simple piece of data.
*
* Unlike Add(std::string_view, wpi::span<const int64_t>), the value in the
* Unlike Add(std::string_view, std::span<const int64_t>), the value in the
* widget will be saved on the robot and will be used when the robot program
* next starts rather than {@code defaultValue}.
*
* @param title the title of the widget
* @param defaultValue the default value of the widget
* @return a widget to display the sendable data
* @see Add(std::string_view, wpi::span<const int64_t>)
* Add(std::string_view title, wpi::span<const int64_t> defaultValue)
* @see Add(std::string_view, std::span<const int64_t>)
* Add(std::string_view title, std::span<const int64_t> defaultValue)
*/
SimpleWidget& AddPersistent(std::string_view title,
wpi::span<const int64_t> defaultValue);
std::span<const int64_t> defaultValue);
/**
* Adds a widget to this container to display a simple piece of data.
*
* Unlike Add(std::string_view, wpi::span<const std::string>), the value in
* Unlike Add(std::string_view, std::span<const std::string>), the value in
* the widget will be saved on the robot and will be used when the robot
* program next starts rather than {@code defaultValue}.
*
* @param title the title of the widget
* @param defaultValue the default value of the widget
* @return a widget to display the sendable data
* @see Add(std::string_view, wpi::span<const std::string>)
* Add(std::string_view title, wpi::span<const std::string> defaultValue)
* @see Add(std::string_view, std::span<const std::string>)
* Add(std::string_view title, std::span<const std::string> defaultValue)
*/
SimpleWidget& AddPersistent(std::string_view title,
wpi::span<const std::string> defaultValue);
std::span<const std::string> defaultValue);
void EnableIfActuator() override;
@@ -721,7 +721,7 @@ inline frc::ComplexWidget& frc::ShuffleboardContainer::Add(
inline frc::ComplexWidget& frc::ShuffleboardContainer::AddCamera(
std::string_view title, std::string_view cameraName,
wpi::span<const std::string> cameraUrls) {
std::span<const std::string> cameraUrls) {
return Add(title, frc::SendableCameraWrapper::Wrap(cameraName, cameraUrls));
}
#endif