summaryrefslogtreecommitdiff
path: root/lib/maths.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/maths.h')
-rw-r--r--lib/maths.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/maths.h b/lib/maths.h
index 32f2884..97b7ef5 100644
--- a/lib/maths.h
+++ b/lib/maths.h
@@ -261,6 +261,19 @@ midpoint(const std::pair<T, T> & v)
return std::midpoint(v.first, v.second);
}
+// std::pow is not constexpr
+template<typename T>
+ requires requires(T n) { n *= n; }
+constexpr inline T
+pow(const T base, std::integral auto exp)
+{
+ T res {1};
+ while (exp--) {
+ res *= base;
+ }
+ return res;
+}
+
// Conversions
template<typename T>
inline constexpr auto