5#include <stratax/exceptions/Exceptions.hpp>
7namespace stratax::indexing {
9using size_type = std::size_t;
10using difference_type = std::ptrdiff_t;
12inline size_type normalize_index(
13 difference_type index,
16 const size_type magnitude = index < 0
17 ?
static_cast<size_type
>(-(index + 1)) + 1
20 if ((index >= 0 &&
static_cast<size_type
>(index) >= size) ||
21 (index < 0 && magnitude > size))
26 return index >= 0 ?
static_cast<size_type
>(index) : size - magnitude;