This commit is contained in:
14
support/3rd_party/include/utils/common.hpp
vendored
14
support/3rd_party/include/utils/common.hpp
vendored
@@ -84,11 +84,15 @@ get_next_available_port(std::uint16_t first_port,
|
||||
|
||||
[[nodiscard]] auto resolve_variables(std::wstring_view str) -> std::wstring;
|
||||
|
||||
// template implementations
|
||||
template <typename val_t>
|
||||
[[nodiscard]] inline auto divide_with_ceiling(const val_t &n,
|
||||
const val_t &d) -> val_t {
|
||||
return n ? (n / d) + (n % d != 0) : 0;
|
||||
template <typename result_t, typename data_t>
|
||||
[[nodiscard]] inline constexpr auto
|
||||
divide_with_ceiling(result_t numerator, data_t denominator) -> result_t {
|
||||
static_assert(std::is_integral_v<std::remove_cv_t<data_t>>,
|
||||
"denominator must be an integral type");
|
||||
|
||||
return denominator == 0
|
||||
? 0
|
||||
: (numerator / denominator) + (numerator % denominator != 0);
|
||||
}
|
||||
|
||||
#if defined(PROJECT_ENABLE_LIBSODIUM)
|
||||
|
Reference in New Issue
Block a user