diff --git a/libnestutil/numerics.cpp b/libnestutil/numerics.cpp index b661142928..8eff885f2a 100644 --- a/libnestutil/numerics.cpp +++ b/libnestutil/numerics.cpp @@ -92,7 +92,7 @@ const double numerics::nan = 0.0 / 0.0; long ld_round( double x ) { - return ( long ) std::floor( x + 0.5 ); + return static_cast< long >( std::floor( x + 0.5 ) ); } double diff --git a/libnestutil/stopwatch.h b/libnestutil/stopwatch.h index fb90f051f1..d30474faa2 100644 --- a/libnestutil/stopwatch.h +++ b/libnestutil/stopwatch.h @@ -71,12 +71,12 @@ class Stopwatch enum { - MICROSEC = ( timeunit_t ) 1, - MILLISEC = MICROSEC * ( timeunit_t ) 1000, - SECONDS = MILLISEC * ( timeunit_t ) 1000, - MINUTES = SECONDS * ( timeunit_t ) 60, - HOURS = MINUTES * ( timeunit_t ) 60, - DAYS = HOURS * ( timeunit_t ) 24 + MICROSEC = static_cast< timeunit_t >( 1 ), + MILLISEC = MICROSEC * static_cast< timeunit_t >( 1000 ), + SECONDS = MILLISEC * static_cast< timeunit_t >( 1000 ), + MINUTES = SECONDS * static_cast< timeunit_t >( 60 ), + HOURS = MINUTES * static_cast< timeunit_t >( 60 ), + DAYS = HOURS * static_cast< timeunit_t >( 24 ) }; static bool correct_timeunit( timeunit_t t ); @@ -222,7 +222,7 @@ nest::Stopwatch::elapsed_timestamp() const return _end - _beg + _prev_elapsed; } #else - return ( timestamp_t ) 0; + return static_cast< timestamp_t >( 0 ); #endif } diff --git a/nestkernel/layer_impl.h b/nestkernel/layer_impl.h index 5ac8ed1d3f..4199ef2f35 100644 --- a/nestkernel/layer_impl.h +++ b/nestkernel/layer_impl.h @@ -382,7 +382,7 @@ MaskedLayer< D >::check_mask_( Layer< D >& layer, bool allow_oversized ) for ( int i = 0; i < D; ++i ) { oversize |= layer.get_periodic_mask()[ i ] - and ( grid_mask.get_lower_right()[ i ] - grid_mask.get_upper_left()[ i ] ) > ( int ) dims[ i ]; + and ( grid_mask.get_lower_right()[ i ] - grid_mask.get_upper_left()[ i ] ) > static_cast< int >( dims[ i ] ); } if ( oversize ) { diff --git a/nestkernel/model.cpp b/nestkernel/model.cpp index 3f34143cec..08d2a342a3 100644 --- a/nestkernel/model.cpp +++ b/nestkernel/model.cpp @@ -69,7 +69,7 @@ Model::set_threads_( size_t t ) void Model::reserve_additional( size_t t, size_t n ) { - assert( ( size_t ) t < memory_.size() ); + assert( t < memory_.size() ); memory_[ t ].reserve( n ); } diff --git a/nestkernel/model.h b/nestkernel/model.h index 26093a8b5e..231228f7ce 100644 --- a/nestkernel/model.h +++ b/nestkernel/model.h @@ -255,7 +255,7 @@ class Model inline Node* Model::create( size_t t ) { - assert( ( size_t ) t < memory_.size() ); + assert( t < memory_.size() ); Node* n = create_(); memory_[ t ].emplace_back( n ); return n; diff --git a/nestkernel/model_manager.cpp b/nestkernel/model_manager.cpp index cb2e7dbe8f..8c7a9eca00 100644 --- a/nestkernel/model_manager.cpp +++ b/nestkernel/model_manager.cpp @@ -366,7 +366,7 @@ size_t ModelManager::get_node_model_id( const Name name ) const { const Name model_name( name ); - for ( int i = 0; i < ( int ) node_models_.size(); ++i ) + for ( int i = 0; i < static_cast< int >( node_models_.size() ); ++i ) { assert( node_models_[ i ] ); if ( model_name == node_models_[ i ]->get_name() ) diff --git a/nestkernel/ring_buffer.h b/nestkernel/ring_buffer.h index 75d744c9ea..9e7328f766 100644 --- a/nestkernel/ring_buffer.h +++ b/nestkernel/ring_buffer.h @@ -169,8 +169,8 @@ RingBuffer::set_value( const long offs, const double v ) inline double RingBuffer::get_value( const long offs ) { - assert( 0 <= offs and ( size_t ) offs < buffer_.size() ); - assert( ( long ) offs < kernel().connection_manager.get_min_delay() ); + assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); + assert( offs < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -183,8 +183,8 @@ RingBuffer::get_value( const long offs ) inline double RingBuffer::get_value_wfr_update( const long offs ) { - assert( 0 <= offs and ( size_t ) offs < buffer_.size() ); - assert( ( long ) offs < kernel().connection_manager.get_min_delay() ); + assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); + assert( offs < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -198,7 +198,7 @@ RingBuffer::get_index_( const long d ) const { const long idx = kernel().event_delivery_manager.get_modulo( d ); assert( 0 <= idx ); - assert( ( size_t ) idx < buffer_.size() ); + assert( static_cast< size_t >( idx ) < buffer_.size() ); return idx; } @@ -258,15 +258,15 @@ class MultRBuffer inline void MultRBuffer::add_value( const long offs, const double v ) { - assert( 0 <= offs and ( size_t ) offs < buffer_.size() ); + assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); buffer_[ get_index_( offs ) ] *= v; } inline double MultRBuffer::get_value( const long offs ) { - assert( 0 <= offs and ( size_t ) offs < buffer_.size() ); - assert( ( long ) offs < kernel().connection_manager.get_min_delay() ); + assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); + assert( offs < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -280,7 +280,7 @@ inline size_t MultRBuffer::get_index_( const long d ) const { const long idx = kernel().event_delivery_manager.get_modulo( d ); - assert( 0 <= idx and ( size_t ) idx < buffer_.size() ); + assert( 0 <= idx and static_cast< size_t >( idx ) < buffer_.size() ); return idx; } @@ -346,8 +346,8 @@ ListRingBuffer::append_value( const long offs, const double v ) inline std::list< double >& ListRingBuffer::get_list( const long offs ) { - assert( 0 <= offs and ( size_t ) offs < buffer_.size() ); - assert( ( long ) offs < kernel().connection_manager.get_min_delay() ); + assert( 0 <= offs and static_cast< size_t >( offs ) < buffer_.size() ); + assert( offs < kernel().connection_manager.get_min_delay() ); // offs == 0 is beginning of slice, but we have to // take modulo into account when indexing @@ -360,7 +360,7 @@ ListRingBuffer::get_index_( const long d ) const { const long idx = kernel().event_delivery_manager.get_modulo( d ); assert( 0 <= idx ); - assert( ( size_t ) idx < buffer_.size() ); + assert( static_cast< size_t >( idx ) < buffer_.size() ); return idx; } diff --git a/nestkernel/simulation_manager.cpp b/nestkernel/simulation_manager.cpp index 060b191325..adc7c67bb6 100644 --- a/nestkernel/simulation_manager.cpp +++ b/nestkernel/simulation_manager.cpp @@ -1080,7 +1080,7 @@ nest::SimulationManager::advance_time_() to_do_ -= to_step_ - from_step_; // advance clock, update modulos, slice counter only if slice completed - if ( ( long ) to_step_ == kernel().connection_manager.get_min_delay() ) + if ( to_step_ == kernel().connection_manager.get_min_delay() ) { clock_ += Time::step( kernel().connection_manager.get_min_delay() ); ++slice_; @@ -1094,7 +1094,7 @@ nest::SimulationManager::advance_time_() long end_sim = from_step_ + to_do_; - if ( kernel().connection_manager.get_min_delay() < ( long ) end_sim ) + if ( kernel().connection_manager.get_min_delay() < end_sim ) { // update to end of time slice to_step_ = kernel().connection_manager.get_min_delay(); @@ -1104,7 +1104,7 @@ nest::SimulationManager::advance_time_() to_step_ = end_sim; // update to end of simulation time } - assert( to_step_ - from_step_ <= ( long ) kernel().connection_manager.get_min_delay() ); + assert( to_step_ - from_step_ <= kernel().connection_manager.get_min_delay() ); } void diff --git a/nestkernel/slice_ring_buffer.h b/nestkernel/slice_ring_buffer.h index c3d7a7df78..62999fbc90 100644 --- a/nestkernel/slice_ring_buffer.h +++ b/nestkernel/slice_ring_buffer.h @@ -159,7 +159,7 @@ inline void SliceRingBuffer::add_spike( const long rel_delivery, const long stamp, const double ps_offset, const double weight ) { const long idx = kernel().event_delivery_manager.get_slice_modulo( rel_delivery ); - assert( ( size_t ) idx < queue_.size() ); + assert( static_cast< size_t >( idx ) < queue_.size() ); assert( ps_offset >= 0 ); queue_[ idx ].push_back( SpikeInfo( stamp, ps_offset, weight ) ); diff --git a/sli/interpret.cc b/sli/interpret.cc index 84d7d4f07e..69a3d0fee8 100644 --- a/sli/interpret.cc +++ b/sli/interpret.cc @@ -987,7 +987,7 @@ SLIInterpreter::stack_backtrace( int n ) { for ( int p = n - 1; p >= 0; --p ) { - if ( ( size_t ) p > EStack.load() ) + if ( static_cast< size_t >( p ) > EStack.load() ) { continue; } diff --git a/sli/scanner.cc b/sli/scanner.cc index 4d2a10047d..101fb0f89c 100644 --- a/sli/scanner.cc +++ b/sli/scanner.cc @@ -139,7 +139,7 @@ Scanner::Scanner( std::istream* is ) code.Group( alpha, "ABCDFGHIJKLMNOPQRSTUVWXYZ" ); code.Group( alpha, "abcdfghijklmopqrsuvwxyz" ); - code.Range( alpha, ( char ) 161, ( char ) 255 ); + code.Range( alpha, static_cast< char >( 161 ), static_cast< char >( 255 ) ); code[ '_' ] = alpha; code.Group( alpha, "~`!@#$^&=|:;'<,>?\"" ); // according to PS diff --git a/sli/sliarray.cc b/sli/sliarray.cc index 6561321c52..a3502a0782 100644 --- a/sli/sliarray.cc +++ b/sli/sliarray.cc @@ -87,13 +87,13 @@ SLIArrayModule::RangeFunction::execute( SLIInterpreter* i ) const { double d = ad->get( 0 ); ad->erase(); - long n = ( long ) std::floor( d ); + long n = static_cast< long >( std::floor( d ) ); if ( n > 0 ) { ad->reserve( n ); for ( long j = 1; j <= n; ++j ) { - ad->push_back( ( double ) j ); + ad->push_back( static_cast< double >( j ) ); } } i->EStack.pop(); @@ -262,7 +262,7 @@ SLIArrayModule::ArangeFunction::execute( SLIInterpreter* i ) const else { double d = ad->get( 0 ); - long n = ( long ) std::floor( d ); + long n = static_cast< long >( std::floor( d ) ); if ( n < 0 ) { i->raiseerror( "RangeCheck" ); @@ -1019,7 +1019,7 @@ SLIArrayModule::IMapFunction::execute( SLIInterpreter* i ) const } } - if ( ( size_t ) procc->get() < proclimit ) + if ( static_cast< size_t >( procc->get() ) < proclimit ) { /* we are still evaluating the procedure. */ i->EStack.push( proc->get( pos ) ); // get next command from the procedure @@ -1046,7 +1046,7 @@ SLIArrayModule::IMapFunction::execute( SLIInterpreter* i ) const } while ( true ); } } - if ( ( size_t ) procc->get() >= proclimit ) + if ( static_cast< size_t >( procc->get() ) >= proclimit ) { ( *procc ) = 0; } @@ -1157,7 +1157,7 @@ SLIArrayModule::IMap_ivFunction::execute( SLIInterpreter* i ) const } } - if ( ( size_t ) procc->get() < proclimit ) + if ( static_cast< size_t >( procc->get() ) < proclimit ) { /* we are still evaluating the procedure. */ i->EStack.push( proc->get( pos ) ); // get next command from the procedure @@ -1184,7 +1184,7 @@ SLIArrayModule::IMap_ivFunction::execute( SLIInterpreter* i ) const } while ( true ); } } - if ( ( size_t ) procc->get() >= proclimit ) + if ( static_cast< size_t >( procc->get() ) >= proclimit ) { ( *procc ) = 0; } @@ -1292,7 +1292,7 @@ SLIArrayModule::IMap_dvFunction::execute( SLIInterpreter* i ) const } } - if ( ( size_t ) procc->get() < proclimit ) + if ( static_cast< size_t >( procc->get() ) < proclimit ) { /* we are still evaluating the procedure. */ i->EStack.push( proc->get( pos ) ); // get next command from the procedure @@ -1319,7 +1319,7 @@ SLIArrayModule::IMap_dvFunction::execute( SLIInterpreter* i ) const } while ( true ); } } - if ( ( size_t ) procc->get() >= proclimit ) + if ( static_cast< size_t >( procc->get() ) >= proclimit ) { ( *procc ) = 0; } @@ -1522,7 +1522,7 @@ SLIArrayModule::IMapIndexedFunction::execute( SLIInterpreter* i ) const } } - if ( ( size_t ) procc->get() < proclimit ) + if ( static_cast< size_t >( procc->get() ) < proclimit ) { /* we are still evaluating the procedure. */ i->EStack.push( proc->get( pos ) ); // get next command from the procedure @@ -1548,7 +1548,7 @@ SLIArrayModule::IMapIndexedFunction::execute( SLIInterpreter* i ) const } while ( true ); } } - if ( ( size_t ) procc->get() >= proclimit ) + if ( static_cast< size_t >( procc->get() ) >= proclimit ) { ( *procc ) = 0; } @@ -1687,7 +1687,7 @@ SLIArrayModule::IMapThreadFunction::execute( SLIInterpreter* i ) const } } - if ( ( size_t ) proccountd->get() < proclimit ) + if ( static_cast< size_t >( proccountd->get() ) < proclimit ) { /* we are still evaluating the procedure. */ // get next command from the procedure @@ -1715,7 +1715,7 @@ SLIArrayModule::IMapThreadFunction::execute( SLIInterpreter* i ) const } while ( true ); } } - if ( ( size_t ) proccountd->get() >= proclimit ) + if ( static_cast< size_t >( proccountd->get() ) >= proclimit ) { ( *proccountd ) = 0; } @@ -1865,7 +1865,7 @@ SLIArrayModule::Put_a_a_tFunction::execute( SLIInterpreter* i ) const return; } - if ( j >= ( int ) source->size() ) + if ( j >= static_cast< int >( source->size() ) ) { i->message( SLIInterpreter::M_ERROR, "Put", "Index out of range." ); i->message( SLIInterpreter::M_ERROR, "Put", "Source array is unchanged." ); @@ -2756,10 +2756,10 @@ SLIArrayModule::GaborFunction::execute( SLIInterpreter* i ) const result.reserve( nrow ); std::vector< double > col( ncol ); - for ( size_t r = 0; r < ( size_t ) nrow; ++r ) + for ( size_t r = 0; r < static_cast< size_t >( nrow ); ++r ) { const double y = ymin + r * dy; - for ( size_t c = 0; c < ( size_t ) ncol; ++c ) + for ( size_t c = 0; c < static_cast< size_t >( ncol ); ++c ) { const double x = xmin + c * dx; const double x1 = x * cos_phi - y * sin_phi; @@ -2862,11 +2862,11 @@ SLIArrayModule::Gauss2dFunction::execute( SLIInterpreter* i ) const result.reserve( nrow ); std::vector< double > col( ncol ); - for ( size_t r = 0; r < ( size_t ) nrow; ++r ) + for ( size_t r = 0; r < static_cast< size_t >( nrow ); ++r ) { const double y = ymin + r * dy; col.assign( ncol, 0.0 ); // clear contents - for ( size_t c = 0; c < ( size_t ) ncol; ++c ) + for ( size_t c = 0; c < static_cast< size_t >( ncol ); ++c ) { const double x = xmin + c * dx; const double x1 = x * cos_phi - y * sin_phi; diff --git a/sli/slicontrol.cc b/sli/slicontrol.cc index 42b3edc828..bb48a39654 100644 --- a/sli/slicontrol.cc +++ b/sli/slicontrol.cc @@ -1550,11 +1550,11 @@ PclocksFunction::execute( SLIInterpreter* i ) const return; } - Token rtime( ( long ) realtime ); - Token utime( ( long ) foo.tms_utime ); - Token stime( ( long ) foo.tms_stime ); - Token cutime( ( long ) foo.tms_cutime ); - Token cstime( ( long ) foo.tms_cstime ); + Token rtime( static_cast< long >( realtime ) ); + Token utime( static_cast< long >( foo.tms_utime ) ); + Token stime( static_cast< long >( foo.tms_stime ) ); + Token cutime( static_cast< long >( foo.tms_cutime ) ); + Token cstime( static_cast< long >( foo.tms_cstime ) ); ArrayDatum result; result.push_back( rtime ); diff --git a/sli/slidata.cc b/sli/slidata.cc index e9c65359f1..7dda31f35b 100644 --- a/sli/slidata.cc +++ b/sli/slidata.cc @@ -66,7 +66,7 @@ Get_aFunction::execute( SLIInterpreter* i ) const assert( obj ); - if ( ( idx->get() >= 0 ) and ( ( size_t ) idx->get() < obj->size() ) ) + if ( ( idx->get() >= 0 ) and ( static_cast< size_t >( idx->get() ) < obj->size() ) ) { i->EStack.pop(); Token objT( obj->get( idx->get() ) ); @@ -113,16 +113,16 @@ Get_a_aFunction::execute( SLIInterpreter* i ) const { std::ostringstream sout; - sout << "Index at position " << ( size_t ) ( t - idx->begin() ) << " ignored." << std::ends; + sout << "Index at position " << static_cast< size_t >( ( t - idx->begin() ) ) << " ignored." << std::ends; i->message( SLIInterpreter::M_INFO, "get_a_a", sout.str().c_str() ); i->message( SLIInterpreter::M_INFO, "get_a_a", "Index must be an integer." ); continue; } - if ( not( ( id->get() >= 0 ) and ( ( size_t ) id->get() < obj->size() ) ) ) + if ( not( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < obj->size() ) ) ) { std::ostringstream sout; - sout << "At position " << ( size_t ) ( t - idx->begin() ) << "." << std::ends; + sout << "At position " << static_cast< size_t >( ( t - idx->begin() ) ) << "." << std::ends; i->message( SLIInterpreter::M_ERROR, "get_a_a", sout.str().c_str() ); i->message( SLIInterpreter::M_ERROR, "get_a_a", "Index out of range." ); i->raiseerror( i->RangeCheckError ); @@ -158,7 +158,7 @@ Get_pFunction::execute( SLIInterpreter* i ) const assert( obj ); - if ( ( idx->get() >= 0 ) and ( ( size_t ) idx->get() < obj->size() ) ) + if ( ( idx->get() >= 0 ) and ( static_cast< size_t >( idx->get() ) < obj->size() ) ) { i->EStack.pop(); Token objT( obj->get( idx->get() ) ); @@ -182,7 +182,7 @@ Get_lpFunction::execute( SLIInterpreter* i ) const LitprocedureDatum* obj = dynamic_cast< LitprocedureDatum* >( i->OStack.pick( 1 ).datum() ); assert( obj ); - if ( ( idx->get() >= 0 ) and ( ( size_t ) idx->get() < obj->size() ) ) + if ( ( idx->get() >= 0 ) and ( static_cast< size_t >( idx->get() ) < obj->size() ) ) { i->EStack.pop(); Token objT( obj->get( idx->get() ) ); @@ -356,7 +356,7 @@ Insert_sFunction::execute( SLIInterpreter* i ) const assert( s1 and id and s2 ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { i->EStack.pop(); s1->insert( id->get(), *s2 ); @@ -392,7 +392,7 @@ InsertElement_sFunction::execute( SLIInterpreter* i ) const assert( s1 and id and c ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { i->EStack.pop(); s1->insert( id->get(), 1, static_cast< char >( c->get() ) ); @@ -448,7 +448,7 @@ Insert_aFunction::execute( SLIInterpreter* i ) const assert( a1 and id and a2 ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < a1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < a1->size() ) ) { i->EStack.pop(); a1->insert_move( id->get(), *a2 ); // ArrayDatum is a TokenArray. @@ -471,7 +471,7 @@ InsertElement_aFunction::execute( SLIInterpreter* i ) const assert( a1 and id ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < a1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < a1->size() ) ) { i->EStack.pop(); a1->insert_move( id->get(), i->OStack.top() ); @@ -545,7 +545,7 @@ Replace_sFunction::execute( SLIInterpreter* i ) const assert( s1 and id and n and s2 ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { if ( n->get() >= 0 ) { @@ -577,7 +577,7 @@ Replace_aFunction::execute( SLIInterpreter* i ) const assert( s1 and id and n and s2 ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { if ( n->get() >= 0 ) { @@ -622,7 +622,7 @@ Erase_sFunction::execute( SLIInterpreter* i ) const assert( s1 and id and n ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { if ( n->get() >= 0 ) { @@ -653,7 +653,7 @@ Erase_aFunction::execute( SLIInterpreter* i ) const assert( s1 and id and n ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { if ( n->get() >= 0 ) { @@ -684,7 +684,7 @@ Erase_pFunction::execute( SLIInterpreter* i ) const assert( s1 and id and n ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { if ( n->get() >= 0 ) { @@ -716,7 +716,7 @@ Put_sFunction::execute( SLIInterpreter* i ) const assert( s1 and id and cd ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < s1->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < s1->size() ) ) { i->EStack.pop(); ( *s1 )[ id->get() ] = static_cast< char >( cd->get() ); @@ -740,7 +740,7 @@ Put_aFunction::execute( SLIInterpreter* i ) const assert( ad and id ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < ad->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < ad->size() ) ) { i->EStack.pop(); ad->assign_move( id->get(), i->OStack.top() ); // its safe to empty top() because @@ -764,7 +764,7 @@ Put_pFunction::execute( SLIInterpreter* i ) const assert( ad and id ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < ad->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < ad->size() ) ) { i->EStack.pop(); ad->assign_move( id->get(), i->OStack.top() ); // its safe to empty top() because @@ -788,7 +788,7 @@ Put_lpFunction::execute( SLIInterpreter* i ) const assert( ad and id ); - if ( ( id->get() >= 0 ) and ( ( size_t ) id->get() < ad->size() ) ) + if ( ( id->get() >= 0 ) and ( static_cast< size_t >( id->get() ) < ad->size() ) ) { i->EStack.pop(); ad->assign_move( id->get(), i->OStack.top() ); // its safe to empty top() because @@ -1402,7 +1402,7 @@ Get_sFunction::execute( SLIInterpreter* i ) const assert( obj ); - if ( ( idx->get() >= 0 ) and ( ( size_t ) idx->get() < obj->size() ) ) + if ( ( idx->get() >= 0 ) and ( static_cast< size_t >( idx->get() ) < obj->size() ) ) { i->EStack.pop(); Token objT( new IntegerDatum( ( *obj )[ idx->get() ] ) ); diff --git a/sli/sligraphics.cc b/sli/sligraphics.cc index c4a8baa534..62eb4ac353 100644 --- a/sli/sligraphics.cc +++ b/sli/sligraphics.cc @@ -193,7 +193,7 @@ SLIgraphics::ReadPGMFunction::readImage( std::istream* in, int tmp; while ( *in >> tmp and not in->eof() ) { - image.push_back( ( long ) tmp ); + image.push_back( static_cast< long >( tmp ) ); } } else if ( std::string( magic ) == std::string( "P5" ) @@ -211,7 +211,7 @@ SLIgraphics::ReadPGMFunction::readImage( std::istream* in, while ( in->read( &tmp, 1 ) and not( in->eof() ) ) { tmp2 = ( unsigned char ) tmp; - image.push_back( ( long ) tmp2 ); + image.push_back( static_cast< long >( tmp2 ) ); } } else @@ -277,9 +277,9 @@ SLIgraphics::WritePGMFunction::execute( SLIInterpreter* i ) const ArrayDatum* image = dynamic_cast< ArrayDatum* >( i->OStack.pick( 3 ).datum() ); StringDatum* filename = dynamic_cast< StringDatum* >( i->OStack.pick( 4 ).datum() ); - long width = ( long ) w->get(); - long height = ( long ) h->get(); - long maxval = ( long ) m->get(); + long width = static_cast< long >( w->get() ); + long height = static_cast< long >( h->get() ); + long maxval = static_cast< long >( m->get() ); std::ostream* out = nullptr; @@ -292,7 +292,7 @@ SLIgraphics::WritePGMFunction::execute( SLIInterpreter* i ) const throw std::string( "Error when opening file for writing." ); } - if ( ( long ) image->size() != width * height ) + if ( static_cast< long >( image->size() ) != width * height ) { throw std::string( "Array size does not match given dimensions." ); } diff --git a/sli/tarrayobj.cc b/sli/tarrayobj.cc index 2a8e978386..965339c6eb 100644 --- a/sli/tarrayobj.cc +++ b/sli/tarrayobj.cc @@ -363,7 +363,7 @@ TokenArrayObj::reduce( Token* first, Token* last ) i->clear(); i++; } - begin_of_free_storage = p + ( size_t ) ( last - first ); + begin_of_free_storage = p + static_cast< size_t >( ( last - first ) ); // shrink(); } diff --git a/sli/tarrayobj.h b/sli/tarrayobj.h index c36730c4bc..abaeee5193 100644 --- a/sli/tarrayobj.h +++ b/sli/tarrayobj.h @@ -80,13 +80,13 @@ class TokenArrayObj size_t size() const { - return ( size_t ) ( begin_of_free_storage - p ); + return static_cast< size_t >( begin_of_free_storage - p ); } size_t capacity() const { - return ( size_t ) ( end_of_free_storage - p ); + return static_cast< size_t >( end_of_free_storage - p ); } Token& diff --git a/testsuite/cpptests/test_block_vector.h b/testsuite/cpptests/test_block_vector.h index ba6e9cc507..83e1a1c3e7 100644 --- a/testsuite/cpptests/test_block_vector.h +++ b/testsuite/cpptests/test_block_vector.h @@ -73,8 +73,8 @@ BOOST_AUTO_TEST_CASE( test_size ) block_vector_b.push_back( i ); } - BOOST_REQUIRE( block_vector_a.size() == ( size_t ) N_a ); - BOOST_REQUIRE( block_vector_b.size() == ( size_t ) N_b ); + BOOST_REQUIRE( block_vector_a.size() == static_cast< size_t >( N_a ) ); + BOOST_REQUIRE( block_vector_b.size() == static_cast< size_t >( N_b ) ); } BOOST_AUTO_TEST_CASE( test_random_access )