Skip to content

Commit d5e238f

Browse files
committed
Add static asserts
1 parent 61c29a3 commit d5e238f

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

include/fplus/numeric.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,8 @@ std::function<X(X)> divide_by(const X& x)
838838
// div_pos_int_ceil(5, 3) == 2
839839
template<typename X>
840840
static auto div_pos_int_ceil(X numerator, X denominator) {
841+
static_assert(std::is_integral<X>::value, "type must be integral");
842+
static_assert(!std::is_signed<X>::value, "type must be unsigned");
841843
return numerator / denominator + (numerator % denominator != 0);
842844
}
843845

include_all_in_one/include/fplus/fplus.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8352,10 +8352,12 @@ std::function<X(X)> divide_by(const X& x)
83528352
}
83538353

83548354
// API search type: div_pos_int_ceil : (a, a) -> a
8355-
// Integer division, but rounding up instead of down.
8355+
// Positive integer division, but rounding up instead of down.
83568356
// div_pos_int_ceil(5, 3) == 2
83578357
template<typename X>
83588358
static auto div_pos_int_ceil(X numerator, X denominator) {
8359+
static_assert(std::is_integral<X>::value, "type must be integral");
8360+
static_assert(!std::is_signed<X>::value, "type must be unsigned");
83598361
return numerator / denominator + (numerator % denominator != 0);
83608362
}
83618363

0 commit comments

Comments
 (0)