Utilize algorithms from std::ranges

The result is shorter code and improves readability.
Note that `asConst()` is still required for non-const containers, otherwise the container will
detach.

PR #23342.
This commit is contained in:
Chocobo1
2025-10-07 01:56:08 +08:00
committed by GitHub
parent 4181a10542
commit d5d690cace
37 changed files with 95 additions and 103 deletions

View File

@@ -87,7 +87,7 @@ namespace
void normalExitHandler(const int signum)
{
const char *msgs[] = {"Catching signal: ", sysSigName[signum], "\nExiting cleanly\n"};
std::for_each(std::begin(msgs), std::end(msgs), safePrint);
std::ranges::for_each(msgs, safePrint);
signal(signum, SIG_DFL);
QMetaObject::invokeMethod(qApp, [] { QCoreApplication::exit(); }, Qt::QueuedConnection); // unsafe, but exit anyway
}
@@ -103,7 +103,7 @@ namespace
const std::string stacktrace = getStacktrace();
const char *msgs[] = {msg, sigName, "\n```\n", stacktrace.c_str(), "```\n\n"};
std::for_each(std::begin(msgs), std::end(msgs), safePrint);
std::ranges::for_each(msgs, safePrint);
#ifndef DISABLE_GUI
StacktraceDialog dlg; // unsafe