Use std::as_const (C++17 feature)

This commit is contained in:
Mat Sutcliffe
2021-04-17 22:21:18 +01:00
parent 6d617f40a4
commit 33209fa1eb
42 changed files with 92 additions and 103 deletions

View File

@@ -44,7 +44,7 @@ namespace BlackCore
QVector<float> buffer;
m_sampleProvider->readSamples(buffer, count);
for (float sample : as_const(buffer))
for (float sample : std::as_const(buffer))
{
const float absSample = qAbs(sample);
if (absSample > m_maxSampleOutput) { m_maxSampleOutput = absSample; }

View File

@@ -282,7 +282,7 @@ namespace BlackCore
// we might have unresolved callsigns
// those are the ones not in range
for (const CCallsign &callsign : as_const(searchList))
for (const CCallsign &callsign : std::as_const(searchList))
{
const CUserList usersByCallsign = sApp->getWebDataServices()->getUsersForCallsign(callsign);
if (usersByCallsign.isEmpty())

View File

@@ -371,7 +371,7 @@ namespace BlackCore
myAircraft.getHeading().normalizedTo360Degrees().value(CAngleUnit::deg()),
myAircraft.getParts().isOnGround());
for (const auto &receiver : as_const(m_interimPositionReceivers))
for (const auto &receiver : std::as_const(m_interimPositionReceivers))
{
interimPilotDataUpdate.setReceiver(receiver.asString());
sendQueudedMessage(interimPilotDataUpdate);
@@ -1774,7 +1774,7 @@ namespace BlackCore
{
emit atisLogoffTimeReplyReceived(sender, message);
CInformationMessage atisMessage(CInformationMessage::ATIS);
for (const auto &line : as_const(pendingQuery.m_atisMessage))
for (const auto &line : std::as_const(pendingQuery.m_atisMessage))
{
if (!atisMessage.isEmpty()) atisMessage.appendMessage("\n");
atisMessage.appendMessage(line);
@@ -1871,7 +1871,7 @@ namespace BlackCore
}
if (callStatistics.isEmpty()) { return QString(); }
for (const auto [key, value] : makePairsRange(as_const(callStatistics)))
for (const auto [key, value] : makePairsRange(std::as_const(callStatistics)))
{
// key is pair.first, value is pair.second
transformed.push_back({ value, key });
@@ -1975,7 +1975,7 @@ namespace BlackCore
if (m_printToConsole) { qDebug() << "FSD Recv=>" << line; }
emitRawFsdMessage(line, false);
for (const QString &str : makeKeysRange(as_const(m_messageTypeMapping)))
for (const QString &str : makeKeysRange(std::as_const(m_messageTypeMapping)))
{
if (line.startsWith(str))
{

View File

@@ -103,7 +103,7 @@ namespace BlackCore
if (action.isEmpty()) { return; }
if (m_actionRelayingEnabled && shouldEmit) { emit remoteActionFromLocal(action, isKeyDown); }
for (const auto &boundAction : as_const(m_boundActions))
for (const auto &boundAction : std::as_const(m_boundActions))
{
if (boundAction.m_action == action)
{
@@ -178,7 +178,7 @@ namespace BlackCore
}
QSet<QString> newActiveActions;
for (const auto [combination, action] : makePairsRange(as_const(m_configuredActions)))
for (const auto [combination, action] : makePairsRange(std::as_const(m_configuredActions)))
{
if (combination.isSubsetOf(currentCombination))
{

View File

@@ -366,7 +366,7 @@ namespace BlackCore
}
// blink mode, toggle aircraft
for (const CSimulatedAircraft &aircraft : as_const(m_highlightedAircraft))
for (const CSimulatedAircraft &aircraft : std::as_const(m_highlightedAircraft))
{
if (m_blinkCycle) { this->callPhysicallyRemoveRemoteAircraft(aircraft.getCallsign(), true); }
else { this->callPhysicallyAddRemoteAircraft(aircraft); }

View File

@@ -169,7 +169,7 @@ namespace BlackCore
const WeatherRequest weatherRequest = m_pendingRequests.constFirst();
const CLength maxDistance(100.0, CLengthUnit::km());
for (IWeatherData *plugin : as_const(m_weatherDataPlugins))
for (IWeatherData *plugin : std::as_const(m_weatherDataPlugins))
{
if (!plugin) { continue; }
if (weatherRequest.filePath.isEmpty())