diff --git a/src/CalcManager/CEngine/scicomm.cpp b/src/CalcManager/CEngine/scicomm.cpp index a72cce15..918fd293 100644 --- a/src/CalcManager/CEngine/scicomm.cpp +++ b/src/CalcManager/CEngine/scicomm.cpp @@ -16,6 +16,8 @@ #include "Header Files/CalcEngine.h" #include "Header Files/CalcUtils.h" +#include + #define IDC_RADSIN IDC_UNARYLAST+1 #define IDC_RADCOS IDC_UNARYLAST+2 #define IDC_RADTAN IDC_UNARYLAST+3 @@ -39,11 +41,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; } @@ -942,7 +944,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 01dd3d3b..26f76c91 100644 --- a/src/CalcManager/CEngine/sciset.cpp +++ b/src/CalcManager/CEngine/sciset.cpp @@ -4,8 +4,11 @@ #include "pch.h" #include "Header Files/CalcEngine.h" +#include + 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 +58,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 +71,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/CalcViewModel/Common/CopyPasteManager.cpp b/src/CalcViewModel/Common/CopyPasteManager.cpp index 7ae2bb96..093fe604 100644 --- a/src/CalcViewModel/Common/CopyPasteManager.cpp +++ b/src/CalcViewModel/Common/CopyPasteManager.cpp @@ -6,6 +6,8 @@ #include "Common/TraceLogger.h" #include "Common/LocalizationSettings.h" +#include + using namespace std; using namespace concurrency; using namespace CalculatorApp; @@ -404,7 +406,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 c1d4dfe2..d37e9647 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 a25aeb18..3cd4967e 100644 --- a/src/CalcViewModel/StandardCalculatorViewModel.cpp +++ b/src/CalcViewModel/StandardCalculatorViewModel.cpp @@ -9,6 +9,8 @@ #include "Common/CopyPasteManager.h" #include "Common/TraceLogger.h" +#include + using namespace CalculatorApp; using namespace CalculatorApp::Common; using namespace CalculatorApp::Common::Automation; @@ -1614,7 +1616,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])) { @@ -1645,7 +1647,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])) { @@ -1672,7 +1674,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])) { @@ -1695,7 +1697,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])) { @@ -1729,7 +1731,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])) {