Luna/libluna/include/luna/Common.h

24 lines
485 B
C
Raw Normal View History

/**
* @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;
}