fix constexpr ig

This commit is contained in:
Tr1NgleDev 2024-11-01 20:36:36 +08:00
parent 642057b32d
commit ce1448a903
3 changed files with 149 additions and 0 deletions

View file

@ -106,14 +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());
# 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
{
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());
# 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
{
return (&x)[i];
}
# endif
# else
return (&x)[i];
# endif
}
// -- Unary arithmetic operators --

View file

@ -171,14 +171,63 @@ 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());
# 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;
}
# 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());
# 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;
}
# if GLM_LANG & GLM_LANG_CXX20_FLAG
}
else
{
return (&x)[i];
}
# endif
# else
return (&x)[i];
# endif
}
// -- Unary arithmetic operators --

View file

@ -362,14 +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());
# 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
{
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());
# 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
{
return (&x)[i];
}
# endif
# else
return (&x)[i];
# endif
}
// -- Unary arithmetic operators --