Some fixes

This commit is contained in:
Aleksandr Orefkov 2026-02-25 14:31:11 +03:00
parent f798e8fbbb
commit a083ff1b8b
2 changed files with 10 additions and 11 deletions

View File

@ -2132,7 +2132,7 @@ public:
K* ptr = str(); K* ptr = str();
capacity -= from; capacity -= from;
for (;;) { for (;;) {
size_t needSize = (size_t)fillFunction(ptr + from, capacity); size_t needSize = static_cast<size_t>(fillFunction(ptr + from, capacity));
if (capacity >= needSize) { if (capacity >= needSize) {
d().set_size(from + needSize); d().set_size(from + needSize);
break; break;

View File

@ -1676,11 +1676,11 @@ struct expr_num : expr_to_std_string<expr_num<K, T>> {
constexpr expr_num(expr_num&& t) noexcept : value(t.value) {} constexpr expr_num(expr_num&& t) noexcept : value(t.value) {}
constexpr size_t length() const noexcept { constexpr size_t length() const noexcept {
value = (T)fromInt(buf + bufSize, value); value = static_cast<T>(fromInt(buf + bufSize, value));
return (size_t)value; return static_cast<size_t>(value);
} }
constexpr K* place(K* ptr) const noexcept { constexpr K* place(K* ptr) const noexcept {
size_t len = (size_t)value; size_t len = static_cast<size_t>(value);
ch_traits<K>::copy(ptr, buf + bufSize - len, len); ch_traits<K>::copy(ptr, buf + bufSize - len, len);
return ptr + len; return ptr + len;
} }
@ -2064,7 +2064,6 @@ template<is_one_of_char_v K, FromIntNumber T, unsigned Radix, f::FmtParamSet FP>
requires (Radix > 1 && Radix <= 36) requires (Radix > 1 && Radix <= 36)
struct expr_integer : expr_to_std_string<expr_integer<K, T, Radix, FP>> { struct expr_integer : expr_to_std_string<expr_integer<K, T, Radix, FP>> {
using symb_type = K; using symb_type = K;
using my_type = expr_num<K, T>;
enum { bufSize = 64 }; enum { bufSize = 64 };
mutable K buf[bufSize]; mutable K buf[bufSize];
@ -2118,7 +2117,7 @@ struct expr_integer : expr_to_std_string<expr_integer<K, T, Radix, FP>> {
} }
} }
constexpr K* place(K* ptr) const noexcept { constexpr K* place(K* ptr) const noexcept {
size_t len = (size_t)value_, all_len = len; size_t len = static_cast<size_t>(value_), all_len = len;
if constexpr (std::is_signed_v<T>) { if constexpr (std::is_signed_v<T>) {
if constexpr (FP::sign != f::int_plus_sign::none) { if constexpr (FP::sign != f::int_plus_sign::none) {
all_len++; all_len++;
@ -3017,7 +3016,7 @@ struct int_convert { // NOLINT
result = negate ? 0 - number : number; result = negate ? 0 - number : number;
if constexpr (CheckOverflow) { if constexpr (CheckOverflow) {
if (error != IntConvertResult::Overflow) { if (error != IntConvertResult::Overflow) {
if (number > std::numeric_limits<T>::max() + (negate ? 1 : 0)) { if (number > (u_type)std::numeric_limits<T>::max() + (negate ? 1 : 0)) {
error = IntConvertResult::Overflow; error = IntConvertResult::Overflow;
} }
} }
@ -3447,8 +3446,8 @@ public:
* ``` * ```
*/ */
constexpr str_piece operator()(ptrdiff_t from, ptrdiff_t len = 0) const noexcept { constexpr str_piece operator()(ptrdiff_t from, ptrdiff_t len = 0) const noexcept {
size_t myLen = _len(), idxStart = from >= 0 ? from : myLen > -from ? myLen + from : 0, size_t myLen = _len(), idxStart = from >= 0 ? from : (ptrdiff_t)myLen > -from ? myLen + from : 0,
idxEnd = len > 0 ? idxStart + len : myLen > -len ? myLen + len : 0; idxEnd = len > 0 ? idxStart + len : (ptrdiff_t)myLen > -len ? myLen + len : 0;
if (idxEnd > myLen) if (idxEnd > myLen)
idxEnd = myLen; idxEnd = myLen;
if (idxStart > idxEnd) if (idxStart > idxEnd)
@ -4226,7 +4225,7 @@ public:
size_t mylen = _len(); size_t mylen = _len();
std::conditional_t<std::is_same_v<T, void>, char, T> results; std::conditional_t<std::is_same_v<T, void>, char, T> results;
str_piece me{_str(), mylen}; str_piece me{_str(), mylen};
for (int i = 0;; i++) { for (size_t i = 0;; i++) {
size_t beginOfDelim = find(delimiter, lendelimiter, offset); size_t beginOfDelim = find(delimiter, lendelimiter, offset);
if (beginOfDelim == str::npos) { if (beginOfDelim == str::npos) {
str_piece last{me.symbols() + offset, me.length() - offset}; str_piece last{me.symbols() + offset, me.length() - offset};
@ -5377,7 +5376,7 @@ struct expr_replaces : expr_to_std_string<expr_replaces<K, N, L>> {
} }
if (matches_.added_ == 0) { if (matches_.added_ == 0) {
return what.place(ptr); return what.place(ptr);
} else if (matches_.added_ == -1) { } else if (matches_.added_ == size_t(-1)) {
// after replaces text become empty // after replaces text become empty
return ptr; return ptr;
} }