Added spaceship operator.

This commit is contained in:
Patrick 2023-01-02 17:12:23 +01:00
parent fc8f4bb442
commit 0f66642e35
Signed by: mewin
GPG Key ID: CEDB412C39B5BC47

33
glm/gtx/spaceship.hpp Normal file
View File

@ -0,0 +1,33 @@
#pragma once
#include <compare>
#include "../detail/qualifier.hpp"
#include "../detail/setup.hpp"
namespace glm
{
template<length_t L, typename T, qualifier Q>
GLM_FUNC_DECL GLM_CONSTEXPR std::strong_ordering operator<=>(const glm::vec<L, T, Q>& left, const glm::vec<L, T, Q>& right)
{
if (left[0] != right[0]) {
return left[0] <=> right[0];
}
if constexpr (L > 1) {
if (left[1] != right[1]) {
return left[1] <=> right[1];
}
}
if constexpr (L > 2) {
if (left[2] != right[2]) {
return left[2] <=> right[2];
}
}
if constexpr (L > 3) {
if (left[3] != right[3]) {
return left[3] <=> right[3];
}
}
return std::strong_ordering::equal;
}
}