Skip to content

Commit ab7c33e

Browse files
committed
Suppress checked iterator warnings
1 parent 77258f6 commit ab7c33e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

include/fmt/core.h

+1
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ class buffer_appender : public std::back_insert_iterator<buffer<T>> {
896896
public:
897897
using std::back_insert_iterator<buffer<T>>::back_insert_iterator;
898898
buffer_appender(base it) : base(it) {}
899+
using _Unchecked_type = buffer_appender; // Mark iterator as checked.
899900

900901
buffer_appender& operator++() {
901902
base::operator++();

include/fmt/format.h

+8-4
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,9 @@ FMT_CONSTEXPR20 OutChar* copy_str(InputIt begin, InputIt end, OutChar* out) {
498498
if (is_constant_evaluated()) {
499499
return copy_str<OutChar, InputIt, OutChar*>(begin, end, out);
500500
}
501-
return std::uninitialized_copy(begin, end, out);
501+
auto size = to_unsigned(end - begin);
502+
std::uninitialized_copy(begin, end, make_checked(out, size));
503+
return out + size;
502504
}
503505

504506
template <typename OutChar, typename InputIt, typename OutputIt,
@@ -1791,10 +1793,12 @@ inline Char* write_significand(Char* out, UInt significand,
17911793
if (!decimal_point)
17921794
return format_decimal(out, significand, significand_size).end;
17931795
auto end = format_decimal(out + 1, significand, significand_size).end;
1794-
if (integral_size == 1)
1796+
if (integral_size == 1) {
17951797
out[0] = out[1];
1796-
else
1797-
std::uninitialized_copy_n(out + 1, integral_size, out);
1798+
} else {
1799+
std::uninitialized_copy_n(out + 1, integral_size,
1800+
make_checked(out, to_unsigned(integral_size)));
1801+
}
17981802
out[integral_size] = decimal_point;
17991803
return end;
18001804
}

0 commit comments

Comments
 (0)