Use C++20 concepts to require constraints on template parameters (#1977)

This commit is contained in:
Rangi
2026-05-22 17:54:34 -04:00
committed by GitHub
parent 728bed39d5
commit dce14fd4b8
12 changed files with 64 additions and 27 deletions
+2 -1
View File
@@ -5,6 +5,7 @@
#include <algorithm>
#include <array>
#include <charconv>
#include <concepts> // unsigned_integral
#include <errno.h>
#include <fstream>
#include <inttypes.h>
@@ -202,7 +203,7 @@ static void warnExtraColors(
}
// Parses the initial part of a string_view, advancing the "read index" as it does
template<typename UintT> // Should be uint*_t
template<std::unsigned_integral UintT>
static std::optional<UintT> parseDec(std::string const &str, size_t &n) {
UintT value = 0;
auto result = std::from_chars(str.data() + n, str.data() + str.length(), value);