annotate Engine/NZIArray.h @ 2531:f6de3e15d4a5

for light in indoor
author Ritor1
date Sun, 23 Nov 2014 15:30:17 +0600
parents 68cdef6879a0
children
rev   line source
2499
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
1 #pragma once
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
2 #include <array>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
3 #include <assert.h>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
4
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
5
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
6 template<class _Ty,
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
7 size_t _Size>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
8 class NZIArray : std::array<_Ty, _Size>
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
9 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
10 public:
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
11 reference ZerothIndex()
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
12 {
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
13 return std::array<_Ty, _Size>::operator [](0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
14 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
15
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
16 reference operator[](size_type _Pos)
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
17 { // subscript nonmutable sequence
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
18 #if _ITERATOR_DEBUG_LEVEL == 2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
19 assert(_Pos != 0 && "not allowed to access zeroth element");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
20
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
21 #elif _ITERATOR_DEBUG_LEVEL == 1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
22 _SCL_SECURE_VALIDATE_RANGE(_Pos != 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
23 #endif /* _ITERATOR_DEBUG_LEVEL */
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
24
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
25 __analysis_assume(_Pos != 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
26
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
27 return std::array<_Ty, _Size>::operator [](_Pos);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
28 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
29
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
30 const_reference operator[](size_type _Pos) const
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
31 { // subscript nonmutable sequence
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
32 #if _ITERATOR_DEBUG_LEVEL == 2
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
33 assert(_Pos != 0 && "not allowed to access zeroth element");
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
34
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
35 #elif _ITERATOR_DEBUG_LEVEL == 1
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
36 _SCL_SECURE_VALIDATE_RANGE(_Pos != 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
37 #endif /* _ITERATOR_DEBUG_LEVEL */
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
38
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
39 __analysis_assume(_Pos != 0);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
40
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
41 return std::array<_Ty, _Size>::operator [](_Pos);
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
42 }
68cdef6879a0 engine folder
Ritor1
parents:
diff changeset
43 };