Skip to content

Commit a083ff1

Browse files
committed
Some fixes
1 parent f798e8f commit a083ff1

2 files changed

Lines changed: 10 additions & 11 deletions

File tree

include/simstr/sstring.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2132,7 +2132,7 @@ class str_mutable {
21322132
K* ptr = str();
21332133
capacity -= from;
21342134
for (;;) {
2135-
size_t needSize = (size_t)fillFunction(ptr + from, capacity);
2135+
size_t needSize = static_cast<size_t>(fillFunction(ptr + from, capacity));
21362136
if (capacity >= needSize) {
21372137
d().set_size(from + needSize);
21382138
break;

include/simstr/strexpr.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,11 +1676,11 @@ struct expr_num : expr_to_std_string<expr_num<K, T>> {
16761676
constexpr expr_num(expr_num&& t) noexcept : value(t.value) {}
16771677

16781678
constexpr size_t length() const noexcept {
1679-
value = (T)fromInt(buf + bufSize, value);
1680-
return (size_t)value;
1679+
value = static_cast<T>(fromInt(buf + bufSize, value));
1680+
return static_cast<size_t>(value);
16811681
}
16821682
constexpr K* place(K* ptr) const noexcept {
1683-
size_t len = (size_t)value;
1683+
size_t len = static_cast<size_t>(value);
16841684
ch_traits<K>::copy(ptr, buf + bufSize - len, len);
16851685
return ptr + len;
16861686
}
@@ -2064,7 +2064,6 @@ template<is_one_of_char_v K, FromIntNumber T, unsigned Radix, f::FmtParamSet FP>
20642064
requires (Radix > 1 && Radix <= 36)
20652065
struct expr_integer : expr_to_std_string<expr_integer<K, T, Radix, FP>> {
20662066
using symb_type = K;
2067-
using my_type = expr_num<K, T>;
20682067

20692068
enum { bufSize = 64 };
20702069
mutable K buf[bufSize];
@@ -2118,7 +2117,7 @@ struct expr_integer : expr_to_std_string<expr_integer<K, T, Radix, FP>> {
21182117
}
21192118
}
21202119
constexpr K* place(K* ptr) const noexcept {
2121-
size_t len = (size_t)value_, all_len = len;
2120+
size_t len = static_cast<size_t>(value_), all_len = len;
21222121
if constexpr (std::is_signed_v<T>) {
21232122
if constexpr (FP::sign != f::int_plus_sign::none) {
21242123
all_len++;
@@ -3017,7 +3016,7 @@ struct int_convert { // NOLINT
30173016
result = negate ? 0 - number : number;
30183017
if constexpr (CheckOverflow) {
30193018
if (error != IntConvertResult::Overflow) {
3020-
if (number > std::numeric_limits<T>::max() + (negate ? 1 : 0)) {
3019+
if (number > (u_type)std::numeric_limits<T>::max() + (negate ? 1 : 0)) {
30213020
error = IntConvertResult::Overflow;
30223021
}
30233022
}
@@ -3447,8 +3446,8 @@ class str_src_algs : public buffer_pointers<K, Impl, Mutable> {
34473446
* ```
34483447
*/
34493448
constexpr str_piece operator()(ptrdiff_t from, ptrdiff_t len = 0) const noexcept {
3450-
size_t myLen = _len(), idxStart = from >= 0 ? from : myLen > -from ? myLen + from : 0,
3451-
idxEnd = len > 0 ? idxStart + len : myLen > -len ? myLen + len : 0;
3449+
size_t myLen = _len(), idxStart = from >= 0 ? from : (ptrdiff_t)myLen > -from ? myLen + from : 0,
3450+
idxEnd = len > 0 ? idxStart + len : (ptrdiff_t)myLen > -len ? myLen + len : 0;
34523451
if (idxEnd > myLen)
34533452
idxEnd = myLen;
34543453
if (idxStart > idxEnd)
@@ -4226,7 +4225,7 @@ class str_src_algs : public buffer_pointers<K, Impl, Mutable> {
42264225
size_t mylen = _len();
42274226
std::conditional_t<std::is_same_v<T, void>, char, T> results;
42284227
str_piece me{_str(), mylen};
4229-
for (int i = 0;; i++) {
4228+
for (size_t i = 0;; i++) {
42304229
size_t beginOfDelim = find(delimiter, lendelimiter, offset);
42314230
if (beginOfDelim == str::npos) {
42324231
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>> {
53775376
}
53785377
if (matches_.added_ == 0) {
53795378
return what.place(ptr);
5380-
} else if (matches_.added_ == -1) {
5379+
} else if (matches_.added_ == size_t(-1)) {
53815380
// after replaces text become empty
53825381
return ptr;
53835382
}

0 commit comments

Comments
 (0)