Luna/libluna/include/luna/Common.h
apio b63a8ff245
All checks were successful
continuous-integration/drone/push Build is passing
libluna: Move get_blocks_from_size to a new header and call it ceil_div instead
2023-08-08 11:58:33 +02:00

24 lines
485 B
C++

/**
* @file Common.h
* @author apio (cloudapio.eu)
* @brief Common utility functions.
*
* @copyright Copyright (c) 2023, the Luna authors.
*
*/
#pragma once
/**
* @brief Divide a by b, rounding the quotient up to the next multiple of b.
*
* @tparam T The type of a and b.
* @param a The dividend.
* @param b The divisor.
* @return constexpr T The result of the operation.
*/
template <typename T> inline constexpr T ceil_div(T a, T b)
{
return (a + (b - 1)) / b;
}