-
Notifications
You must be signed in to change notification settings - Fork 2
/
test_elementsof.cpp
67 lines (53 loc) · 1.15 KB
/
test_elementsof.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "test_elementsof.hpp"
#include <cstddef>
#include <cstdlib>
//https://msdn.microsoft.com/en-us/library/ms175773.aspx
#define ENABLE 0
#if ENABLE
template <typename T>
constexpr std::size_t countofA(T & a)
{
return sizeof(a) / sizeof(a[0]);
}
template <typename T, std::size_t N>
constexpr std::size_t countof(T const (&)[N])
{
return N;
}
enum shader
{
SHADER_VERT,
SHADER_FRAG,
SHADER_LAST = SHADER_FRAG
};
std::size_t ProgramNames[] =
{
1,
2
};
static_assert(countof(ProgramNames) == SHADER_LAST + 1, "GNI");
void AttachPipelinePrograms(std::size_t PipelineName, std::size_t const (&ProgramNames)[SHADER_LAST + 1])
{
static std::size_t const ShaderBit[] = // Implicitly sized
{
1 << 0, // STAGE_VERTEX
1 << 1 // STAGE_FRAGMENT
};
std::size_t const Count = countof(ProgramNames);
for(std::size_t i = 0; i < Count; ++i)
{}
}
void test_countof()
{
std::size_t * pointer = NULL;
std::size_t const A = countof(ProgramNames);
//std::size_t const B = countof(pointer);
//std::size_t const B = countofB(pointer);
//std::size_t const C = _countof(ShaderStage);
//std::size_t const D = _countof(pointer);
}
#else
void test_countof()
{
}
#endif