Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 44 additions & 12 deletions glm/detail/type_vec2.inl
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,60 @@ namespace glm
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T & vec<2, T, Q>::operator[](typename vec<2, T, Q>::length_type i)
{
GLM_ASSERT_LENGTH(i, this->length());
switch(i)

#if GLM_LANG & GLM_LANG_CXX14_FLAG || GLM_LANG & GLM_LANG_CXX17_FLAG
#if GLM_LANG & GLM_LANG_CXX20_FLAG
if (std::is_constant_evaluated())
{
#endif
switch (i)
{
default:
case 0:
return x;
case 1:
return y;
}
#if GLM_LANG & GLM_LANG_CXX20_FLAG
}
else
{
default:
case 0:
return x;
case 1:
return y;
return (&x)[i];
}
#endif
#else
return (&x)[i];
#endif
}

template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& vec<2, T, Q>::operator[](typename vec<2, T, Q>::length_type i) const
{
GLM_ASSERT_LENGTH(i, this->length());
switch(i)

#if GLM_LANG & GLM_LANG_CXX14_FLAG || GLM_LANG & GLM_LANG_CXX17_FLAG
#if GLM_LANG & GLM_LANG_CXX20_FLAG
if (std::is_constant_evaluated())
{
#endif
switch (i)
{
default:
case 0:
return x;
case 1:
return y;
}
#if GLM_LANG & GLM_LANG_CXX20_FLAG
}
else
{
default:
case 0:
return x;
case 1:
return y;
return (&x)[i];
}
#endif
#else
return (&x)[i];
#endif
}

// -- Unary arithmetic operators --
Expand Down
58 changes: 45 additions & 13 deletions glm/detail/type_vec3.inl
Original file line number Diff line number Diff line change
Expand Up @@ -171,32 +171,64 @@ namespace glm
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T & vec<3, T, Q>::operator[](typename vec<3, T, Q>::length_type i)
{
GLM_ASSERT_LENGTH(i, this->length());
switch(i)

#if GLM_LANG & GLM_LANG_CXX14_FLAG || GLM_LANG & GLM_LANG_CXX17_FLAG
#if GLM_LANG & GLM_LANG_CXX20_FLAG
if (std::is_constant_evaluated())
{
default:
#endif
switch (i)
{
default:
case 0:
return x;
return x;
case 1:
return y;
return y;
case 2:
return z;
return z;
}
#if GLM_LANG & GLM_LANG_CXX20_FLAG
}
else
{
return (&x)[i];
}
#endif
#else
return (&x)[i];
#endif
}

template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& vec<3, T, Q>::operator[](typename vec<3, T, Q>::length_type i) const
{
GLM_ASSERT_LENGTH(i, this->length());
switch(i)

#if GLM_LANG & GLM_LANG_CXX14_FLAG || GLM_LANG & GLM_LANG_CXX17_FLAG
#if GLM_LANG & GLM_LANG_CXX20_FLAG
if (std::is_constant_evaluated())
{
default:
case 0:
return x;
case 1:
return y;
case 2:
return z;
#endif
switch (i)
{
default:
case 0:
return x;
case 1:
return y;
case 2:
return z;
}
#if GLM_LANG & GLM_LANG_CXX20_FLAG
}
else
{
return (&x)[i];
}
#endif
#else
return (&x)[i];
#endif
}

// -- Unary arithmetic operators --
Expand Down
72 changes: 52 additions & 20 deletions glm/detail/type_vec4.inl
Original file line number Diff line number Diff line change
Expand Up @@ -362,36 +362,68 @@ namespace detail
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T& vec<4, T, Q>::operator[](typename vec<4, T, Q>::length_type i)
{
GLM_ASSERT_LENGTH(i, this->length());
switch (i)

#if GLM_LANG & GLM_LANG_CXX14_FLAG || GLM_LANG & GLM_LANG_CXX17_FLAG
#if GLM_LANG & GLM_LANG_CXX20_FLAG
if (std::is_constant_evaluated())
{
#endif
switch (i)
{
default:
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
}
#if GLM_LANG & GLM_LANG_CXX20_FLAG
}
else
{
default:
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
return (&x)[i];
}
#endif
#else
return (&x)[i];
#endif
}

template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER GLM_CONSTEXPR T const& vec<4, T, Q>::operator[](typename vec<4, T, Q>::length_type i) const
{
GLM_ASSERT_LENGTH(i, this->length());
switch (i)

#if GLM_LANG & GLM_LANG_CXX14_FLAG || GLM_LANG & GLM_LANG_CXX17_FLAG
#if GLM_LANG & GLM_LANG_CXX20_FLAG
if (std::is_constant_evaluated())
{
#endif
switch (i)
{
default:
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
}
#if GLM_LANG & GLM_LANG_CXX20_FLAG
}
else
{
default:
case 0:
return x;
case 1:
return y;
case 2:
return z;
case 3:
return w;
return (&x)[i];
}
#endif
#else
return (&x)[i];
#endif
}

// -- Unary arithmetic operators --
Expand Down
4 changes: 2 additions & 2 deletions glm/gtx/dual_quaternion.inl
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ namespace glm
template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER typename tdualquat<T, Q>::part_type & tdualquat<T, Q>::operator[](typename tdualquat<T, Q>::length_type i)
{
assert(i >= 0 && i < this->length());
GLM_ASSERT_LENGTH(i, this->length());
return (&real)[i];
}

template<typename T, qualifier Q>
GLM_FUNC_QUALIFIER typename tdualquat<T, Q>::part_type const& tdualquat<T, Q>::operator[](typename tdualquat<T, Q>::length_type i) const
{
assert(i >= 0 && i < this->length());
GLM_ASSERT_LENGTH(i, this->length());
return (&real)[i];
}

Expand Down
Loading