Template Function nvcv::detail::AlignUp

Function Documentation

template<typename T>
constexpr T nvcv::detail::AlignUp(T value, T alignment_pow2)

Aligns the value up to a multiple of alignment_pow2.

The function operates by adding alignment-1 to the value and masking the least significant bits. If the alignment is not a power of two, the behavior is undefined.

Remark

Negative values are aligned up, that is, towards zero.

Template Parameters:

T – an integral type

Parameters:
  • value – a value to align

  • alignment_pow2 – the alignment, must be a positive power of 2

Returns:

constexpr T the value aligned up to a multiple of alignment_pow2