@@ -45,7 +45,7 @@ constexpr uint8_t singleToHex(char c) {
45
45
}
46
46
47
47
template <typename Str> // Should be std::string or std::string_view
48
- static void skipWhitespace (Str const &str, typename Str::size_type &pos) {
48
+ static void skipWhitespace (Str const &str, size_t &pos) {
49
49
pos = std::min (str.find_first_not_of (" \t " sv, pos), str.length ());
50
50
}
51
51
@@ -54,9 +54,8 @@ void parseInlinePalSpec(char const * const rawArg) {
54
54
// Palettes are separated by colons.
55
55
56
56
std::string_view arg (rawArg);
57
- using size_type = decltype (arg)::size_type;
58
57
59
- auto parseError = [&rawArg, &arg](size_type ofs, size_type len, char const *msg) {
58
+ auto parseError = [&rawArg, &arg](size_t ofs, size_t len, char const *msg) {
60
59
(void )arg; // With NDEBUG, `arg` is otherwise not used
61
60
assume (ofs <= arg.length ());
62
61
assume (len <= arg.length ());
@@ -80,7 +79,7 @@ void parseInlinePalSpec(char const * const rawArg) {
80
79
options.palSpec .clear ();
81
80
options.palSpec .emplace_back (); // Value-initialized, not default-init'd, so we get zeros
82
81
83
- size_type n = 0 ; // Index into the argument
82
+ size_t n = 0 ; // Index into the argument
84
83
// TODO: store max `nbColors` ever reached, and compare against palette size later
85
84
size_t nbColors = 0 ; // Number of colors in the current palette
86
85
for (;;) {
@@ -222,7 +221,7 @@ static bool readLine(std::filebuf &file, std::string &buffer) {
222
221
223
222
// Parses the initial part of a string_view, advancing the "read index" as it does
224
223
template <typename U> // Should be uint*_t
225
- static std::optional<U> parseDec (std::string const &str, std::string::size_type &n) {
224
+ static std::optional<U> parseDec (std::string const &str, size_t &n) {
226
225
uintmax_t value = 0 ;
227
226
auto result = std::from_chars (str.data () + n, str.data () + str.size (), value);
228
227
if (static_cast <bool >(result.ec )) {
@@ -233,7 +232,7 @@ static std::optional<U> parseDec(std::string const &str, std::string::size_type
233
232
}
234
233
235
234
static std::optional<Rgba>
236
- parseColor (std::string const &str, std::string::size_type &n, uint16_t i) {
235
+ parseColor (std::string const &str, size_t &n, uint16_t i) {
237
236
std::optional<uint8_t > r = parseDec<uint8_t >(str, n);
238
237
if (!r) {
239
238
error (" Failed to parse color #%d (\" %s\" ): invalid red component" , i + 1 , str.c_str ());
@@ -281,7 +280,7 @@ static void parsePSPFile(std::filebuf &file) {
281
280
282
281
line.clear ();
283
282
requireLine (" PSP" , file, line);
284
- std::string::size_type n = 0 ;
283
+ size_t n = 0 ;
285
284
std::optional<uint16_t > nbColors = parseDec<uint16_t >(line, n);
286
285
if (!nbColors || n != line.length ()) {
287
286
error (" Invalid \" number of colors\" line in PSP file (%s)" , line.c_str ());
@@ -347,7 +346,7 @@ static void parseGPLFile(std::filebuf &file) {
347
346
continue ;
348
347
}
349
348
350
- std::string::size_type n = 0 ;
349
+ size_t n = 0 ;
351
350
skipWhitespace (line, n);
352
351
// Skip empty lines, or lines that contain just a comment.
353
352
if (line.length () == n || line[n] == ' #' ) {
@@ -604,7 +603,7 @@ void parseExternalPalSpec(char const *arg) {
604
603
};
605
604
606
605
auto iter =
607
- std::find_if (RANGE (parsers), [&arg, &ptr](decltype (parsers)::value_type const &parser) {
606
+ std::find_if (RANGE (parsers), [&arg, &ptr](auto const &parser) {
608
607
return strncasecmp (arg, std::get<0 >(parser), ptr - arg) == 0 ;
609
608
});
610
609
if (iter == parsers.end ()) {
0 commit comments