Port from qAsConst() to std::as_const()

We've been requiring C++17 since Qt 6.0, and our qAsConst use finally
starts to bother us (QTBUG-99313), so time to port away from it
now.

Since qAsConst has exactly the same semantics as std::as_const (down
to rvalue treatment, constexpr'ness and noexcept'ness), there's really
nothing more to it than a global search-and-replace.

Task-number: QTBUG-99313
Change-Id: I88edd91395849574436299b8badda21bb93bea39
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Marc Mutz
2022-10-07 14:46:06 +02:00
parent 90de29d530
commit 8eb4d52342
498 changed files with 1270 additions and 1270 deletions

View File

@@ -130,7 +130,7 @@ SuppressionDialog::SuppressionDialog(MemcheckErrorView *view, const QList<Error>
m_fileChooser->setPromptDialogTitle(Tr::tr("Select Suppression File"));
QString suppressions;
for (const Error &error : qAsConst(m_errors))
for (const Error &error : std::as_const(m_errors))
suppressions += suppressionText(error);
m_suppressionEdit->setPlainText(suppressions);
@@ -153,7 +153,7 @@ void SuppressionDialog::maybeShow(MemcheckErrorView *view)
indices.append(view->selectionModel()->currentIndex());
QList<XmlProtocol::Error> errors;
for (const QModelIndex &index : qAsConst(indices)) {
for (const QModelIndex &index : std::as_const(indices)) {
Error error = view->model()->data(index, ErrorListModel::ErrorRole).value<Error>();
if (!error.suppression().isNull())
errors.append(error);
@@ -198,7 +198,7 @@ void SuppressionDialog::accept()
return l.row() > r.row();
});
QAbstractItemModel *model = m_view->model();
for (const QModelIndex &index : qAsConst(indices)) {
for (const QModelIndex &index : std::as_const(indices)) {
bool removed = model->removeRow(index.row());
QTC_ASSERT(removed, qt_noop());
Q_UNUSED(removed)
@@ -209,7 +209,7 @@ void SuppressionDialog::accept()
const Error rowError = model->data(
model->index(row, 0), ErrorListModel::ErrorRole).value<Error>();
for (const Error &error : qAsConst(m_errors)) {
for (const Error &error : std::as_const(m_errors)) {
if (equalSuppression(rowError, error)) {
bool removed = model->removeRow(row);
QTC_CHECK(removed);