xieite::wrap()

Defined in fragment xieite:wrap
(header-only: <xieite/math/wrap.hpp>)


Takes the modulo of a number between two limits. The upper limit is exclusive.


Declaration

template<xieite::is_arith T>
[[nodiscard]] constexpr T wrap(T value, T limit0, T limit1) noexcept;


Example

import xieite;

int main() {
	for (int i = 0; i < 10; ++i) {
		xieite::dump(xieite::wrap(i, 4, -2));
	}
}
Output:
0
1
2
3
-2
-1
0
1
2
3
[View in Compiler Explorer]