diff --git a/src/core/algorithm/periodic_fold.hpp b/src/core/algorithm/periodic_fold.hpp index 6e00e42a42..ccdf8f0929 100644 --- a/src/core/algorithm/periodic_fold.hpp +++ b/src/core/algorithm/periodic_fold.hpp @@ -20,9 +20,18 @@ #define CORE_ALGORITHM_PERIODIC_FOLD_HPP #include +#include #include +#include #include +// Define a concept that checks if a type T is an integer or a reference to an +// integer +template +concept IntegralOrRef = std::integral>; +template +concept FloatingPointOrRef = std::floating_point>; + namespace Algorithm { /** * @brief Fold value into primary interval. @@ -32,7 +41,7 @@ namespace Algorithm { * @param l Length of primary interval * @return x folded into [0, l) and number of folds. */ -template +template std::pair periodic_fold(T x, I i, T const l) { using limits = std::numeric_limits; @@ -56,7 +65,7 @@ std::pair periodic_fold(T x, I i, T const l) { * @param l Length of primary interval * @return x folded into [0, l). */ -template T periodic_fold(T x, T const l) { +template T periodic_fold(T x, T const l) { #ifndef __FAST_MATH__ /* Can't fold if either x or l is nan or inf. */ if (std::isnan(x) or std::isnan(l) or std::isinf(x) or (l == 0)) {