xte::wrap()

Defined in header <xte/math/wrap.hpp>

Computes modulo between two inclusive limits. Casts arguments to their common type.


Definition

[[nodiscard]] constexpr auto wrap(xte::is_number auto x, xte::is_number auto limit0, xte::is_number auto limit1) noexcept;



Example

for (int i = -1; i <= 5; ++i) {
	std::println("{}", xte::wrap(i, 1, 3));
}
Output:
2
3
1
2
3
1
2
[View in Compiler Explorer]