diff --git a/src/CalcManager/CEngine/scicomm.cpp b/src/CalcManager/CEngine/scicomm.cpp index 2ebb027..8a741bb 100644 --- a/src/CalcManager/CEngine/scicomm.cpp +++ b/src/CalcManager/CEngine/scicomm.cpp @@ -39,11 +39,11 @@ namespace { int iPrec; iPrec = 0; - while ((iPrec < ARRAYSIZE(rgbPrec)) && (nopCode != rgbPrec[iPrec])) + while ((iPrec < size(rgbPrec)) && (nopCode != rgbPrec[iPrec])) { iPrec += 2; } - if (iPrec >= ARRAYSIZE(rgbPrec)) + if (iPrec >= size(rgbPrec)) { iPrec = 0; } @@ -947,7 +947,7 @@ wstring_view CCalcEngine::OpCodeToUnaryString(int nOpCode, bool fInv, ANGLE_TYPE // Try to lookup the ID in the UFNE table int ids = 0; int iufne = nOpCode - IDC_UNARYFIRST; - if (iufne >= 0 && iufne < ARRAYSIZE(rgUfne)) + if (iufne >= 0 && iufne < size(rgUfne)) { if (fInv) { diff --git a/src/CalcManager/CEngine/sciset.cpp b/src/CalcManager/CEngine/sciset.cpp index 01dd3d3..d5bbe9d 100644 --- a/src/CalcManager/CEngine/sciset.cpp +++ b/src/CalcManager/CEngine/sciset.cpp @@ -6,6 +6,7 @@ using namespace CalcEngine; using namespace CalcEngine::RationalMath; +using namespace std; // To be called when either the radix or num width changes. You can use -1 in either of these values to mean // dont change that. @@ -55,7 +56,7 @@ LONG CCalcEngine::DwWordBitWidthFromeNumWidth(NUM_WIDTH /*numwidth*/) static constexpr int nBitMax[] = { 64, 32, 16, 8 }; LONG wmax = nBitMax[0]; - if (m_numwidth >= 0 && m_numwidth < ARRAYSIZE(nBitMax)) + if (m_numwidth >= 0 && m_numwidth < size(nBitMax)) { wmax = nBitMax[m_numwidth]; } @@ -68,7 +69,7 @@ uint32_t CCalcEngine::NRadixFromRadixType(RADIX_TYPE radixtype) uint32_t radix = 10; // convert special bases into symbolic values - if (radixtype >= 0 && radixtype < ARRAYSIZE(rgnRadish)) + if (radixtype >= 0 && radixtype < size(rgnRadish)) { radix = rgnRadish[radixtype]; } diff --git a/src/CalcManager/pch.h b/src/CalcManager/pch.h index 27e01ff..4690713 100644 --- a/src/CalcManager/pch.h +++ b/src/CalcManager/pch.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include diff --git a/src/CalcViewModel/Common/CopyPasteManager.cpp b/src/CalcViewModel/Common/CopyPasteManager.cpp index 7ae2bb9..71215d4 100644 --- a/src/CalcViewModel/Common/CopyPasteManager.cpp +++ b/src/CalcViewModel/Common/CopyPasteManager.cpp @@ -404,7 +404,7 @@ wstring CopyPasteManager::SanitizeOperand(const wstring& operand) { wchar_t unWantedChars[] = { L'\'', L'_', L'`', L'(', L')', L'-' }; - return Utils::RemoveUnwantedCharsFromWstring(operand, unWantedChars, ARRAYSIZE(unWantedChars)); + return Utils::RemoveUnwantedCharsFromWstring(operand, unWantedChars, static_cast(size(unWantedChars))); } bool CopyPasteManager::TryOperandToULL(const wstring& operand, int numberBase, unsigned long long int& result) diff --git a/src/CalcViewModel/Common/LocalizationSettings.h b/src/CalcViewModel/Common/LocalizationSettings.h index c1d4dfe..d37e964 100644 --- a/src/CalcViewModel/Common/LocalizationSettings.h +++ b/src/CalcViewModel/Common/LocalizationSettings.h @@ -4,6 +4,8 @@ #pragma once #include "LocalizationService.h" +#include + namespace CalculatorApp { namespace Common @@ -41,7 +43,7 @@ namespace CalculatorApp result = GetLocaleInfoEx(m_resolvedName.c_str(), LOCALE_SDECIMAL, decimalString, - ARRAYSIZE(decimalString)); + static_cast(std::size(decimalString))); if (result == 0) { throw std::runtime_error("Unexpected error while getting locale info"); @@ -51,7 +53,7 @@ namespace CalculatorApp result = GetLocaleInfoEx(m_resolvedName.c_str(), LOCALE_STHOUSAND, groupingSymbolString, - ARRAYSIZE(groupingSymbolString)); + static_cast(std::size(groupingSymbolString))); if (result == 0) { throw std::runtime_error("Unexpected error while getting locale info"); @@ -61,7 +63,7 @@ namespace CalculatorApp result = GetLocaleInfoEx(m_resolvedName.c_str(), LOCALE_SGROUPING, numberGroupingString, - ARRAYSIZE(numberGroupingString)); + static_cast(std::size(numberGroupingString))); if (result == 0) { throw std::runtime_error("Unexpected error while getting locale info"); @@ -72,7 +74,7 @@ namespace CalculatorApp result = ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_SLIST, listSeparatorString, - ARRAYSIZE(listSeparatorString)); // Max length of the expected return value is 4 + static_cast(std::size(listSeparatorString))); // Max length of the expected return value is 4 if (result == 0) { throw std::runtime_error("Unexpected error while getting locale info"); @@ -122,7 +124,7 @@ namespace CalculatorApp ::GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, // The first day in a week reinterpret_cast(day), // Argument is of type PWSTR - ARRAYSIZE(day)); // Max return size are 80 characters + static_cast(std::size(day))); // Max return size are 80 characters // The LOCALE_IFIRSTDAYOFWEEK integer value varies from 0, 1, .. 6 for Monday, Tuesday, ... Sunday // DayOfWeek enum value varies from 0, 1, .. 6 for Sunday, Monday, ... Saturday diff --git a/src/CalcViewModel/StandardCalculatorViewModel.cpp b/src/CalcViewModel/StandardCalculatorViewModel.cpp index e97ffbe..b035c14 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -1647,7 +1647,7 @@ bool StandardCalculatorViewModel::IsOpnd(int nOpCode) Command::CommandPNT }; - for (int i = 0; i < ARRAYSIZE(opnd); i++) + for (int i = 0; i < size(opnd); i++) { if (nOpCode == static_cast(opnd[i])) { @@ -1678,7 +1678,7 @@ bool StandardCalculatorViewModel::IsUnaryOp(int nOpCode) Command::CommandCUB }; - for (int i = 0; i < ARRAYSIZE(unaryOp); i++) + for (int i = 0; i < size(unaryOp); i++) { if (nOpCode == static_cast(unaryOp[i])) { @@ -1705,7 +1705,7 @@ bool StandardCalculatorViewModel::IsTrigOp(int nOpCode) Command::CommandATAN }; - for (int i = 0; i < ARRAYSIZE(trigOp); i++) + for (int i = 0; i < size(trigOp); i++) { if (nOpCode == static_cast(trigOp[i])) { @@ -1728,7 +1728,7 @@ bool StandardCalculatorViewModel::IsBinOp(int nOpCode) Command::CommandPWR }; - for (int i = 0; i < ARRAYSIZE(binOp); i++) + for (int i = 0; i < size(binOp); i++) { if (nOpCode == static_cast(binOp[i])) { @@ -1762,7 +1762,7 @@ bool StandardCalculatorViewModel::IsRecoverableCommand(int nOpCode) Command::CommandF }; - for (int i = 0; i < ARRAYSIZE(recoverableCommands); i++) + for (int i = 0; i < size(recoverableCommands); i++) { if (nOpCode == static_cast(recoverableCommands[i])) { diff --git a/src/CalcViewModel/pch.h b/src/CalcViewModel/pch.h index b2717d1..1d03c5e 100644 --- a/src/CalcViewModel/pch.h +++ b/src/CalcViewModel/pch.h @@ -26,7 +26,7 @@ #include #include #include - +#include // C++\WinRT Headers #include "winrt/base.h" #include "winrt/Windows.Foundation.Diagnostics.h"