From c52d129db10ade5d75269727fe495787c4104f14 Mon Sep 17 00:00:00 2001 From: Jan Date: Sun, 20 Mar 2022 17:38:23 +0100 Subject: [PATCH] Add alignment utility --- src/Utils/Utils/Alignment.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/Utils/Utils/Alignment.h diff --git a/src/Utils/Utils/Alignment.h b/src/Utils/Utils/Alignment.h new file mode 100644 index 00000000..9b0ba20d --- /dev/null +++ b/src/Utils/Utils/Alignment.h @@ -0,0 +1,12 @@ +#pragma once + +namespace utils +{ + template + constexpr T Align(T value, T toNext) + { + if (toNext > 0) + return (value + toNext - 1) / toNext * toNext; + return value; + } +}