Replace SFINAE with concepts (#5361)

Concepts are cleaner to use and result in much better error messages for incorrect template use.
This commit is contained in:
Tyler Veness
2023-06-07 09:50:09 -07:00
committed by GitHub
parent d57d1a4598
commit 91cbcea841
42 changed files with 397 additions and 361 deletions

View File

@@ -4,17 +4,16 @@
#include "glass/Storage.h"
#include <type_traits>
#include <imgui.h>
#include <wpi/StringExtras.h>
#include <wpi/concepts.h>
#include <wpi/json.h>
using namespace glass;
template <typename To>
bool ConvertFromString(To* out, std::string_view str) {
if constexpr (std::is_same_v<To, bool>) {
if constexpr (std::same_as<To, bool>) {
if (str == "true") {
*out = true;
} else if (str == "false") {
@@ -24,7 +23,7 @@ bool ConvertFromString(To* out, std::string_view str) {
} else {
return false;
}
} else if constexpr (std::is_floating_point_v<To>) {
} else if constexpr (std::floating_point<To>) {
if (auto val = wpi::parse_float<To>(str)) {
*out = val.value();
} else {