comparison Engine/NZIArray.h @ 2499:68cdef6879a0

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