Replace custom ARRAYSIZE macro with std::size (#208)

* Replace custom ARRAYSIZE macro with std::size
This commit is contained in:
Michał Janiszewski
2019-03-15 05:06:12 +01:00
committed by Daniel Belcher
parent d37c75fec2
commit a5e07418df
7 changed files with 21 additions and 17 deletions

View File

@@ -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)
{

View File

@@ -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];
}

View File

@@ -12,6 +12,7 @@
#include <winerror.h>
#include <sstream>
#include <iostream>
#include <iterator>
#include <string>
#include <memory>
#include <vector>