add static assertion to prevent lossy type conversion

This commit is contained in:
Yancey 2026-03-04 07:17:05 +08:00 committed by GitHub
parent 1ff672025a
commit 744bff33f4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1808,7 +1808,7 @@ template <typename T> class buffer {
/// Appends data to the end of the buffer.
template <typename U>
FMT_CONSTEXPR20 void append(const U* begin, const U* end) {
static_assert(std::is_same<T, U>::value || std::is_same<U, char>::value);
static_assert(std::is_same<T, U>::value || std::is_same<U, char>::value, "");
while (begin != end) {
auto size = size_;
auto free_cap = capacity_ - size;