Skip to content

Commit 0a236db

Browse files
committed
update
1 parent 08ab89b commit 0a236db

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

include/geode/basic/range.hpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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

src/geode/mesh/helpers/rasterize.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -685,18 +685,18 @@ namespace
685685
void fill_values( const geode::Triangle2D& triangle )
686686
{
687687
const auto bbox = triangle.bounding_box();
688-
const auto max_j = std::floor(
688+
const auto max_j = static_cast< geode::index_t >( std::floor(
689689
bbox.max().value( 0 ) / grid_.cell_length_in_direction( 1 )
690-
- 0.5 );
691-
const auto max_k = std::floor(
690+
- 0.5 ) );
691+
const auto max_k = static_cast< geode::index_t >( std::floor(
692692
bbox.max().value( 1 ) / grid_.cell_length_in_direction( 2 )
693-
- 0.5 );
694-
const auto min_j = std::ceil(
693+
- 0.5 ) );
694+
const auto min_j = static_cast< geode::index_t >( std::ceil(
695695
bbox.min().value( 0 ) / grid_.cell_length_in_direction( 1 )
696-
- 0.5 );
697-
const auto min_k = std::ceil(
696+
- 0.5 ) );
697+
const auto min_k = static_cast< geode::index_t >( std::ceil(
698698
bbox.min().value( 1 ) / grid_.cell_length_in_direction( 2 )
699-
- 0.5 );
699+
- 0.5 ) );
700700
const auto max_i_grid = grid_.nb_cells_in_direction( 0 ) - 1;
701701
for( const auto j : geode::Range{ min_j, max_j + 1 } )
702702
{

tests/common.hpp.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ namespace geode
4646
try \
4747
{ \
4848
geode::OpenGeodeBasicLibrary::initialize(); \
49+
geode::Logger::set_level( geode::Logger::LEVEL::trace ); \
4950
test(); \
5051
\
5152
geode::Logger::info( "TEST SUCCESS" ); \

0 commit comments

Comments
 (0)