gz-cpp-util 1.3
A c++20 library containing various utilities
util.hpp File Reference

Various utilites. More...

#include <concepts>

Go to the source code of this file.

Functions

template<std::unsigned_integral I, std::unsigned_integral S>
void gz::util::incrementIndex (I &i, const S containerSize)
 Increment an index. Up to containerSize, then restart at 0.
 
template<std::unsigned_integral I, std::unsigned_integral S>
void gz::util::decrementIndex (I &i, const S containerSize)
 Decrement an index. Down to 0, then restart at containerSize - 1.
 
template<std::unsigned_integral I, std::unsigned_integral S>
gz::util::getIncrementedIndex (const I i, const S containerSize)
 Like incrementIndex, but returns a new number.
 
template<std::unsigned_integral I, std::unsigned_integral S>
gz::util::getDecrementedIndex (const I i, const S containerSize)
 Like decrementIndex, but returns a new number.
 
template<std::integral I, std::unsigned_integral S>
std::size_t gz::util::getValidIndex (const I i, const S containerSize)
 Wrap an index around, to make it valid. More...
 

Detailed Description

Various utilites.

Function Documentation

◆ getValidIndex()

template<std::integral I, std::unsigned_integral S>
std::size_t gz::util::getValidIndex ( const I  i,
const S  containerSize 
)

Wrap an index around, to make it valid.

Example:

  • i = containerSize + 2 -> return 2
  • i = -2 -> return (containerSize - 1) - 2