diff Engine/NZIArray.h @ 2499:68cdef6879a0

engine folder
author Ritor1
date Fri, 19 Sep 2014 02:57:42 +0600
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Engine/NZIArray.h	Fri Sep 19 02:57:42 2014 +0600
@@ -0,0 +1,43 @@
+#pragma once
+#include <array>
+#include <assert.h>
+
+
+template<class _Ty,
+  size_t _Size>
+class NZIArray : std::array<_Ty, _Size>
+{
+public:
+  reference ZerothIndex()
+  {
+    return std::array<_Ty, _Size>::operator [](0);
+  }
+
+  reference operator[](size_type _Pos)
+  {	// subscript nonmutable sequence
+#if _ITERATOR_DEBUG_LEVEL == 2
+    assert(_Pos != 0 && "not allowed to access zeroth element");
+
+#elif _ITERATOR_DEBUG_LEVEL == 1
+    _SCL_SECURE_VALIDATE_RANGE(_Pos != 0);
+#endif /* _ITERATOR_DEBUG_LEVEL */
+
+    __analysis_assume(_Pos != 0);
+
+    return std::array<_Ty, _Size>::operator [](_Pos);
+  }
+
+  const_reference operator[](size_type _Pos) const
+  {	// subscript nonmutable sequence
+#if _ITERATOR_DEBUG_LEVEL == 2
+    assert(_Pos != 0 && "not allowed to access zeroth element");
+
+#elif _ITERATOR_DEBUG_LEVEL == 1
+    _SCL_SECURE_VALIDATE_RANGE(_Pos != 0);
+#endif /* _ITERATOR_DEBUG_LEVEL */
+
+    __analysis_assume(_Pos != 0);
+
+    return std::array<_Ty, _Size>::operator [](_Pos);
+  }
+};