From 540d63ce5b0243ce395d468d6c0a0adff936d74c Mon Sep 17 00:00:00 2001 From: lisyarus Date: Wed, 28 Feb 2024 16:59:08 +0300 Subject: [PATCH] Add geom::compare_swap utility function --- libs/geom/include/psemek/geom/math.hpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libs/geom/include/psemek/geom/math.hpp b/libs/geom/include/psemek/geom/math.hpp index 8e3d832d..21066c2b 100644 --- a/libs/geom/include/psemek/geom/math.hpp +++ b/libs/geom/include/psemek/geom/math.hpp @@ -196,6 +196,17 @@ namespace psemek::geom return false; } + template + bool compare_swap(T & min, T & max) + { + if (min > max) + { + std::swap(min, max); + return true; + } + return false; + } + template T smoothstep(T x) {