Skip to content

Commit f04f935

Browse files
committed
Support arbitrary integral types in bounded::assume_in_range
1 parent 284f073 commit f04f935

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

source/bounded/integer.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ concept bounded_by_range = overlapping_integer<T, minimum, maximum> and detail::
8080

8181
namespace detail {
8282

83-
export template<integral T, bounded_integer Minimum, bounded_integer Maximum>
83+
export template<integral T, integral Minimum, integral Maximum>
8484
constexpr auto assume_in_range_impl(T const value, Minimum, Maximum) {
8585
return integer<
8686
normalize<detail::safe_max(builtin_min_value<Minimum>, builtin_min_value<T>)>,
@@ -90,7 +90,7 @@ constexpr auto assume_in_range_impl(T const value, Minimum, Maximum) {
9090

9191
} // namespace detail
9292

93-
export constexpr auto assume_in_range(integral auto const value, bounded_integer auto const minimum, bounded_integer auto const maximum) {
93+
export constexpr auto assume_in_range(integral auto const value, integral auto const minimum, integral auto const maximum) {
9494
if (value < minimum or maximum < value) {
9595
std::unreachable();
9696
}
@@ -242,6 +242,7 @@ static_assert(bounded::isomorphic_to_integral<bounded::integer<0, 1>>);
242242
static_assert(bounded::assume_in_range(bounded::constant<5>, bounded::constant<0>, bounded::constant<10>) == bounded::constant<5>);
243243
// This should not compile
244244
// constexpr auto value2 = bounded::assume_in_range(15, bounded::constant<0>, bounded::constant<10>);
245+
static_assert(bounded::assume_in_range(2, 1, 3) == bounded::integer(2));
245246

246247
static_assert(homogeneous_equals(bounded::normalize<bounded::constant<0>>, 0));
247248

0 commit comments

Comments
 (0)