Add assertions for out-of-bounds indices.

This commit is contained in:
King_DuckZ 2014-08-22 10:49:22 +02:00
parent 105020b5c1
commit 78734f6ad3

View file

@ -24,6 +24,7 @@
#include <ciso646>
#include <type_traits>
#include <algorithm>
#include <cassert>
#if !defined(NDEBUG)
#include <iostream>
@ -65,8 +66,8 @@ namespace cloonel {
template <typename U> const Vector& operator*= ( U parOther );
template <typename U> const Vector& operator/= ( U parOther );
T& operator[] ( uint32_t parIndex ) { return m_mem[parIndex]; }
const T& operator[] ( uint32_t parIndex ) const { return m_mem[parIndex]; }
T& operator[] ( uint32_t parIndex ) { assert(parIndex < S); return m_mem[parIndex]; }
const T& operator[] ( uint32_t parIndex ) const { assert(parIndex < S); return m_mem[parIndex]; }
private:
T m_mem[S];