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

@ -138,7 +138,7 @@ bool cfg::try_to_uint64(u64* out, const std::string& value, u64 min, u64 max)
bool cfg::try_to_enum_value(u64* out, decltype(&fmt_class_string<int>::format) func, const std::string& value)
{
u64 max = -1;
u64 max = umax;
for (u64 i = 0;; i++)
{

View file

@ -530,7 +530,7 @@ static std::basic_string<u32> apply_modification(const patch_engine::patch_info&
auto ptr = dst + offset;
u32 resval = -1;
u32 resval = umax;
switch (p.type)
{

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();
}