Replaced _countof / ARRAYSIZE with std::size

This commit is contained in:
Chuck Walbourn 2021-01-02 12:51:18 -08:00
parent b2540d7313
commit 9a03a2843d
3 changed files with 12 additions and 8 deletions

View File

@ -24,6 +24,7 @@
#include "Mesh.h"
#include <cstring>
#include <iterator>
#include <utility>
#include "SDKMesh.h"
@ -1917,7 +1918,7 @@ HRESULT Mesh::ExportToSDKMESH(const wchar_t* szFileName,
{ 0xFF, 0, D3DDECLTYPE_UNUSED, 0, 0, 0 },
};
static_assert((_countof(s_elements) + 1) == _countof(s_decls), "InputLayouts and Vertex Decls disagree");
static_assert((std::size(s_elements) + 1) == std::size(s_decls), "InputLayouts and Vertex Decls disagree");
uint8_t normalType;
size_t normalStride;
@ -2061,7 +2062,7 @@ HRESULT Mesh::ExportToSDKMESH(const wchar_t* szFileName,
}
assert(nDecl < MAX_VERTEX_ELEMENTS);
vbHeader.Decl[nDecl] = s_decls[_countof(s_decls) - 1];
vbHeader.Decl[nDecl] = s_decls[std::size(s_decls) - 1];
// Build vertex buffer
std::unique_ptr<uint8_t> vb(new (std::nothrow) uint8_t[mnVerts * stride]);

View File

@ -24,6 +24,8 @@
#include "Mesh.h"
#include "WaveFrontReader.h"
#include <iterator>
using namespace DirectX;
namespace
@ -87,7 +89,7 @@ HRESULT LoadFromOBJ(
};
const D3D11_INPUT_ELEMENT_DESC* layout = s_vboLayout;
size_t nDecl = _countof(s_vboLayout);
size_t nDecl = std::size(s_vboLayout);
if (!wfReader.hasNormals && !wfReader.hasTexcoords)
{
@ -100,7 +102,7 @@ HRESULT LoadFromOBJ(
else if (!wfReader.hasNormals && wfReader.hasTexcoords)
{
layout = s_vboLayoutAlt;
nDecl = _countof(s_vboLayoutAlt);
nDecl = std::size(s_vboLayoutAlt);
}
VBReader vbr;

View File

@ -26,6 +26,7 @@
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iterator>
#include <memory>
#include <list>
@ -342,7 +343,7 @@ namespace
wchar_t version[32] = {};
wchar_t appName[_MAX_PATH] = {};
if (GetModuleFileNameW(nullptr, appName, _countof(appName)))
if (GetModuleFileNameW(nullptr, appName, static_cast<DWORD>(std::size(appName))))
{
DWORD size = GetFileVersionInfoSizeW(appName, nullptr);
if (size > 0)
@ -1283,9 +1284,9 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
if (dwOptions & (DWORD64(1) << OPT_COLOR_MESH))
{
inMaterial.clear();
inMaterial.reserve(_countof(g_ColorList));
inMaterial.reserve(std::size(g_ColorList));
for (size_t j = 0; j < _countof(g_ColorList) && (j < outCharts); ++j)
for (size_t j = 0; j < std::size(g_ColorList) && (j < outCharts); ++j)
{
Mesh::Material mtl = {};
@ -1314,7 +1315,7 @@ int __cdecl wmain(_In_ int argc, _In_z_count_(argc) wchar_t* argv[])
size_t j = 0;
for (auto it = facePartitioning.cbegin(); it != facePartitioning.cend(); ++it, ++j)
{
attr[j] = *it % _countof(g_ColorList);
attr[j] = *it % std::size(g_ColorList);
}
hr = inMesh->UpdateAttributes(nFaces, attr.get());