Simplify umax

Add operator less and conversion operator.
This commit is contained in:
Nekotekina 2021-04-29 00:13:12 +03:00
parent b1736b6411
commit 5724d2d4c7
4 changed files with 11 additions and 27 deletions

View file

@ -7,8 +7,6 @@
#include <algorithm>
#include "util/asm.hpp"
static const usz size_dropped = -1;
/*
C-style format parser. Appends formatted string to `out`, returns number of characters written.
`out`: mutable reference to std::string, std::vector<char> or other compatible container
@ -43,7 +41,7 @@ usz cfmt_append(Dst& out, const Char* fmt, Src&& src)
const auto drop_sequence = [&]
{
out.insert(out.end(), fmt - ctx.size, fmt);
ctx.size = size_dropped;
ctx.size = umax;
};
const auto read_decimal = [&](uint result) -> uint
@ -143,7 +141,7 @@ usz cfmt_append(Dst& out, const Char* fmt, Src&& src)
ctx = {0};
out.push_back(ch);
}
else if (ctx.size == size_dropped)
else if (ctx.size == umax)
{
out.push_back(ch);
}
@ -694,7 +692,7 @@ usz cfmt_append(Dst& out, const Char* fmt, Src&& src)
}
// Handle unfinished sequence
if (ctx.size && ctx.size != size_dropped)
if (ctx.size && ctx.size != umax)
{
fmt--, drop_sequence();
}