From cab263a56d392f8aec79d6efc321a5d5be1aad9f Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Mon, 2 Jan 2023 17:12:23 +0100 Subject: [PATCH] Added spaceship operator. --- glm/gtx/spaceship.hpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 glm/gtx/spaceship.hpp diff --git a/glm/gtx/spaceship.hpp b/glm/gtx/spaceship.hpp new file mode 100644 index 00000000..c5d073cf --- /dev/null +++ b/glm/gtx/spaceship.hpp @@ -0,0 +1,36 @@ + +#pragma once + +#include +#include "../detail/qualifier.hpp" +#include "../detail/setup.hpp" + +namespace glm +{ + template + struct vec; + + template + GLM_FUNC_DECL GLM_CONSTEXPR std::strong_ordering operator<=>(const vec& left, const vec& 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; + } +} \ No newline at end of file