@@ -83,12 +83,17 @@ namespace geode
8383 {
8484 if constexpr ( std::is_arithmetic_v< Type > )
8585 {
86- OPENGEODE_EXCEPTION ( begin <= static_cast < T1 >(
87- std::numeric_limits< Type >::max () ),
88- " [Range] Invalid range" );
89- OPENGEODE_EXCEPTION ( end <= static_cast < T2 >(
90- std::numeric_limits< Type >::max () ),
91- " [Range] Invalid range" );
86+ using T1U = std::make_unsigned_t < T1 >;
87+ using T2U = std::make_unsigned_t < T2 >;
88+ const auto beginU = static_cast < T1U >( begin );
89+ const auto endU = static_cast < T2U >( end );
90+ OPENGEODE_EXCEPTION (
91+ beginU <= std::numeric_limits< Type >::max (),
92+ " [Range] Invalid range: " , begin, " > " ,
93+ std::numeric_limits< Type >::max () );
94+ OPENGEODE_EXCEPTION ( endU <= std::numeric_limits< Type >::max (),
95+ " [Range] Invalid range: " , end, " > " ,
96+ std::numeric_limits< Type >::max () );
9297 }
9398 }
9499
@@ -124,7 +129,8 @@ namespace geode
124129 }
125130
126131 template < typename T >
127- constexpr explicit TRange ( T end ) : TRange( 0 , end )
132+ constexpr explicit TRange ( T end )
133+ : TRange( static_cast < Type >( 0 ), end )
128134 {
129135 }
130136
@@ -157,7 +163,9 @@ namespace geode
157163 }
158164
159165 template < typename T >
160- constexpr explicit TReverseRange ( T begin ) : TReverseRange( begin, 0 )
166+ constexpr explicit TReverseRange ( T begin )
167+ : BaseRange< Type, DecrementOperator >(
168+ begin - 1 , static_cast < Type >( -1 ) )
161169 {
162170 }
163171
@@ -185,7 +193,8 @@ namespace geode
185193 public:
186194 template < typename Container >
187195 constexpr explicit TIndices ( const Container& container )
188- : BaseRange< Type, IncrementOperator >( 0 , container.size() )
196+ : BaseRange< Type, IncrementOperator >(
197+ static_cast < Type >( 0 ), container.size() )
189198 {
190199 }
191200
0 commit comments