Fix fmt::replace_all with empty from and add unit tests

This commit is contained in:
Megamouse 2025-04-30 23:18:46 +02:00
parent 259768e896
commit 486e93f418
3 changed files with 223 additions and 1 deletions

View file

@ -748,6 +748,12 @@ void fmt::raw_append(std::string& out, const char* fmt, const fmt_type_info* sup
std::string fmt::replace_all(std::string_view src, std::string_view from, std::string_view to, usz count)
{
if (src.empty())
return {};
if (from.empty() || count == 0)
return std::string(src);
std::string target;
target.reserve(src.size() + to.size());