diff --git a/glm/detail/setup.hpp b/glm/detail/setup.hpp index 35cf07652..209ccc859 100644 --- a/glm/detail/setup.hpp +++ b/glm/detail/setup.hpp @@ -614,8 +614,10 @@ #ifdef GLM_FORCE_SIZE_T_LENGTH # define GLM_CONFIG_LENGTH_TYPE GLM_LENGTH_SIZE_T +# define GLM_ASSERT_LENGTH(l, max) (assert ((l) < (max))) #else # define GLM_CONFIG_LENGTH_TYPE GLM_LENGTH_INT +# define GLM_ASSERT_LENGTH(l, max) (assert ((l) >= 0 && (l) < (max))) #endif namespace glm diff --git a/glm/detail/type_mat2x2.inl b/glm/detail/type_mat2x2.inl index 88eca20b4..afb2b31e5 100644 --- a/glm/detail/type_mat2x2.inl +++ b/glm/detail/type_mat2x2.inl @@ -219,14 +219,14 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 2, T, Q>::col_type& mat<2, 2, T, Q>::operator[](typename mat<2, 2, T, Q>::length_type i) GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 2, T, Q>::col_type const& mat<2, 2, T, Q>::operator[](typename mat<2, 2, T, Q>::length_type i) const GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } diff --git a/glm/detail/type_mat2x3.inl b/glm/detail/type_mat2x3.inl index 88077518f..345ac8ac6 100644 --- a/glm/detail/type_mat2x3.inl +++ b/glm/detail/type_mat2x3.inl @@ -219,14 +219,14 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 3, T, Q>::col_type & mat<2, 3, T, Q>::operator[](typename mat<2, 3, T, Q>::length_type i) GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 3, T, Q>::col_type const& mat<2, 3, T, Q>::operator[](typename mat<2, 3, T, Q>::length_type i) const GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } diff --git a/glm/detail/type_mat2x4.inl b/glm/detail/type_mat2x4.inl index e70753c06..1c182c9dd 100644 --- a/glm/detail/type_mat2x4.inl +++ b/glm/detail/type_mat2x4.inl @@ -221,14 +221,14 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 4, T, Q>::col_type & mat<2, 4, T, Q>::operator[](typename mat<2, 4, T, Q>::length_type i) GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<2, 4, T, Q>::col_type const& mat<2, 4, T, Q>::operator[](typename mat<2, 4, T, Q>::length_type i) const GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } diff --git a/glm/detail/type_mat3x2.inl b/glm/detail/type_mat3x2.inl index 5a1b4c010..cd9f46ccc 100644 --- a/glm/detail/type_mat3x2.inl +++ b/glm/detail/type_mat3x2.inl @@ -238,14 +238,14 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 2, T, Q>::col_type & mat<3, 2, T, Q>::operator[](typename mat<3, 2, T, Q>::length_type i) GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 2, T, Q>::col_type const& mat<3, 2, T, Q>::operator[](typename mat<3, 2, T, Q>::length_type i) const GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } diff --git a/glm/detail/type_mat3x3.inl b/glm/detail/type_mat3x3.inl index ddb00d46b..a9b633ae2 100644 --- a/glm/detail/type_mat3x3.inl +++ b/glm/detail/type_mat3x3.inl @@ -240,14 +240,14 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 3, T, Q>::col_type & mat<3, 3, T, Q>::operator[](typename mat<3, 3, T, Q>::length_type i) GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 3, T, Q>::col_type const& mat<3, 3, T, Q>::operator[](typename mat<3, 3, T, Q>::length_type i) const GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } diff --git a/glm/detail/type_mat3x4.inl b/glm/detail/type_mat3x4.inl index 5e2eccd85..209e9d90b 100644 --- a/glm/detail/type_mat3x4.inl +++ b/glm/detail/type_mat3x4.inl @@ -244,14 +244,14 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 4, T, Q>::col_type & mat<3, 4, T, Q>::operator[](typename mat<3, 4, T, Q>::length_type i) GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<3, 4, T, Q>::col_type const& mat<3, 4, T, Q>::operator[](typename mat<3, 4, T, Q>::length_type i) const GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } diff --git a/glm/detail/type_mat4x2.inl b/glm/detail/type_mat4x2.inl index 1a4f3f168..2b9b617a3 100644 --- a/glm/detail/type_mat4x2.inl +++ b/glm/detail/type_mat4x2.inl @@ -257,14 +257,14 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 2, T, Q>::col_type & mat<4, 2, T, Q>::operator[](typename mat<4, 2, T, Q>::length_type i) GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 2, T, Q>::col_type const& mat<4, 2, T, Q>::operator[](typename mat<4, 2, T, Q>::length_type i) const GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } diff --git a/glm/detail/type_mat4x3.inl b/glm/detail/type_mat4x3.inl index c2fe3a445..8430bc07a 100644 --- a/glm/detail/type_mat4x3.inl +++ b/glm/detail/type_mat4x3.inl @@ -257,14 +257,14 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 3, T, Q>::col_type & mat<4, 3, T, Q>::operator[](typename mat<4, 3, T, Q>::length_type i) GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 3, T, Q>::col_type const& mat<4, 3, T, Q>::operator[](typename mat<4, 3, T, Q>::length_type i) const GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } diff --git a/glm/detail/type_mat4x4.inl b/glm/detail/type_mat4x4.inl index db7767316..116731d74 100644 --- a/glm/detail/type_mat4x4.inl +++ b/glm/detail/type_mat4x4.inl @@ -288,14 +288,14 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 4, T, Q>::col_type & mat<4, 4, T, Q>::operator[](typename mat<4, 4, T, Q>::length_type i) GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } template GLM_FUNC_QUALIFIER GLM_CONSTEXPR typename mat<4, 4, T, Q>::col_type const& mat<4, 4, T, Q>::operator[](typename mat<4, 4, T, Q>::length_type i) const GLM_NOEXCEPT { - assert(i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); return this->value[i]; } diff --git a/glm/detail/type_quat.inl b/glm/detail/type_quat.inl index 3213ea6aa..9a0a0f07b 100644 --- a/glm/detail/type_quat.inl +++ b/glm/detail/type_quat.inl @@ -74,7 +74,7 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T & qua::operator[](typename qua::length_type i) { - assert(i >= 0 && i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); # ifdef GLM_FORCE_QUAT_DATA_WXYZ return (&w)[i]; # else @@ -85,7 +85,7 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& qua::operator[](typename qua::length_type i) const { - assert(i >= 0 && i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); # ifdef GLM_FORCE_QUAT_DATA_WXYZ return (&w)[i]; # else diff --git a/glm/detail/type_vec2.inl b/glm/detail/type_vec2.inl index 24850965b..e8408997f 100644 --- a/glm/detail/type_vec2.inl +++ b/glm/detail/type_vec2.inl @@ -105,7 +105,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T & vec<2, T, Q>::operator[](typename vec<2, T, Q>::length_type i) { - assert(i >= 0 && i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); switch(i) { default: @@ -119,7 +119,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& vec<2, T, Q>::operator[](typename vec<2, T, Q>::length_type i) const { - assert(i >= 0 && i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); switch(i) { default: diff --git a/glm/detail/type_vec3.inl b/glm/detail/type_vec3.inl index 5a258d1f9..4e44047ba 100644 --- a/glm/detail/type_vec3.inl +++ b/glm/detail/type_vec3.inl @@ -169,7 +169,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T & vec<3, T, Q>::operator[](typename vec<3, T, Q>::length_type i) { - assert(i >= 0 && i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); switch(i) { default: @@ -185,7 +185,7 @@ namespace glm template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& vec<3, T, Q>::operator[](typename vec<3, T, Q>::length_type i) const { - assert(i >= 0 && i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); switch(i) { default: diff --git a/glm/detail/type_vec4.inl b/glm/detail/type_vec4.inl index 440de5fcb..d48fae758 100644 --- a/glm/detail/type_vec4.inl +++ b/glm/detail/type_vec4.inl @@ -478,7 +478,7 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T& vec<4, T, Q>::operator[](typename vec<4, T, Q>::length_type i) { - assert(i >= 0 && i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); switch(i) { default: @@ -496,7 +496,7 @@ namespace detail template GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& vec<4, T, Q>::operator[](typename vec<4, T, Q>::length_type i) const { - assert(i >= 0 && i < this->length()); + GLM_ASSERT_LENGTH(i, this->length()); switch(i) { default: