Changeset 402 for trunk/src/stl
- Timestamp:
- 06/13/15 21:51:27 (10 years ago)
- Location:
- trunk/src/stl
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/stl/assert.cc
r396 r402 31 31 extern "C" { 32 32 extern void __assert(const char *, const char *, unsigned int, const char *) 33 throw()__attribute__ ((__noreturn__));33 __attribute__ ((__noreturn__)); 34 34 } 35 35 # else 36 36 extern "C" { 37 37 extern void __assert_fail(const char *, const char *, unsigned int, const char *) 38 throw()__attribute__ ((__noreturn__));38 __attribute__ ((__noreturn__)); 39 39 } 40 40 # endif 41 void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function )41 __attribute__( ( __noreturn__ ) ) void nv_internal_assert( const char * assertion, const char * file, unsigned int line, const char * function ) 42 42 { 43 43 # if NV_COMPILER == NV_CLANG -
trunk/src/stl/hash_table.cc
r395 r402 47 47 }; 48 48 49 static const nv::uint32 s_primes_size = ( sizeof( s_primes ) / sizeof( *s_primes ) );49 //static const nv::uint32 s_primes_size = ( sizeof( s_primes ) / sizeof( *s_primes ) ); 50 50 51 51 namespace nv 52 52 { 53 void* g_hash_table_empty[2] = { nullptr, (void*)uintptr_t( ~0) };53 void* g_hash_table_empty[2] = { nullptr, reinterpret_cast<void*>( uintptr_t( ~0 ) ) }; 54 54 } 55 55 -
trunk/src/stl/string.cc
r395 r402 15 15 using namespace nv; 16 16 17 static const double s_power_10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 18 10000000, 100000000, 1000000000 }; 17 //static const double s_power_10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 }; 19 18 20 19 std::string nv::slurp( const std::string& filename ) … … 41 40 { 42 41 char* s = str; 43 uint32 abs = ( n < 0 ) ? (uint32)( -n ) : (uint32)(n );42 uint32 abs = static_cast< uint32 >( n < 0 ? -n : n ); 44 43 do 45 44 { 46 *s++ = (char)( '0' + ( abs % 10 ) );45 *s++ = static_cast<char>( '0' + ( abs % 10 ) ); 47 46 abs /= 10; 48 47 } while ( abs > 0 ); … … 50 49 *s = '\0'; 51 50 string_reverse( str, s - 1 ); 52 return (nv::size_t)( s - str );51 return static_cast<nv::size_t>( s - str ); 53 52 } 54 53 … … 56 55 { 57 56 char* s = str; 58 uint64 abs = ( n < 0 ) ? (uint64)( -n ) : (uint64)(n );57 uint64 abs = static_cast< uint64 >( n < 0 ? -n : n ); 59 58 do 60 59 { 61 *s++ = (char)( '0' + ( abs % 10 ) );60 *s++ = static_cast<char>( '0' + ( abs % 10 ) ); 62 61 abs /= 10; 63 62 } while ( abs > 0 ); … … 65 64 *s = '\0'; 66 65 string_reverse( str, s - 1 ); 67 return (nv::size_t)( s - str );66 return static_cast<nv::size_t>( s - str ); 68 67 } 69 68 … … 73 72 do 74 73 { 75 *s++ = (char)( '0' + ( n % 10 ) );74 *s++ = static_cast<char>( '0' + ( n % 10 ) ); 76 75 n /= 10; 77 76 } while ( n > 0 ); 78 77 *s = '\0'; 79 78 string_reverse( str, s - 1 ); 80 return (nv::size_t)( s - str );79 return static_cast<nv::size_t>( s - str ); 81 80 } 82 81 … … 86 85 do 87 86 { 88 *s++ = (char)( '0' + ( n % 10 ) );87 *s++ = static_cast<char>( '0' + ( n % 10 ) ); 89 88 n /= 10; 90 89 } while ( n > 0 ); 91 90 *s = '\0'; 92 91 string_reverse( str, s - 1 ); 93 return (size_t)( s - str );92 return static_cast<nv::size_t>( s - str ); 94 93 } 95 94 … … 101 100 int result = snprintf( str, 64, "%.*g", 6, n ); 102 101 #endif 103 return result > 0 ? ( nv::size_t )result : 0;102 return static_cast<nv::size_t>( result > 0 ? result : 0 ); 104 103 } 105 104 … … 111 110 int result = snprintf( str, 64, "%.*g", 6, n ); 112 111 #endif 113 return result > 0 ? ( nv::size_t )result : 0;112 return static_cast<nv::size_t>( result > 0 ? result : 0 ); 114 113 } 115 114 116 sint32 buffer_to_sint32( const char* str, char** end )115 sint32 nv::buffer_to_sint32( const char* str, char** end ) 117 116 { 118 117 const char* s = str; … … 131 130 ++s; 132 131 } 133 if ( end != nullptr ) *end = (char*)s;132 if ( end != nullptr ) *end = const_cast<char*>( s ); 134 133 return positive ? result : -result; 135 134 } 136 135 137 sint64 buffer_to_sint64( const char* s, char** end )136 sint64 nv::buffer_to_sint64( const char* s, char** end ) 138 137 { 139 138 while ( *s == ' ' ) ++s; … … 151 150 ++s; 152 151 } 153 if ( end != nullptr ) *end = (char*)s;152 if ( end != nullptr ) *end = const_cast<char*>( s ); 154 153 return positive ? result : -result; 155 154 } 156 155 157 uint32 buffer_to_uint32( const char* s, char** end )156 uint32 nv::buffer_to_uint32( const char* s, char** end ) 158 157 { 159 158 while ( *s == ' ' ) ++s; … … 161 160 while ( *s >= '0' && *s <= '9' ) 162 161 { 163 result = ( result * 10 ) + (uint32)( *s - '0' );162 result = ( result * 10 ) + static_cast<uint32>( *s - '0' ); 164 163 ++s; 165 164 } 166 if ( end != nullptr ) *end = (char*)s;165 if ( end != nullptr ) *end = const_cast<char*>( s ); 167 166 return result; 168 167 } 169 168 170 uint64 buffer_to_uint64( const char* s, char** end )169 uint64 nv::buffer_to_uint64( const char* s, char** end ) 171 170 { 172 171 while ( *s == ' ' ) ++s; … … 174 173 while ( *s >= '0' && *s <= '9' ) 175 174 { 176 result = ( result * 10 ) + (uint32)( *s - '0' );175 result = ( result * 10 ) + static_cast<uint32>( *s - '0' ); 177 176 ++s; 178 177 } 179 if ( end != nullptr ) *end = (char*)s;178 if ( end != nullptr ) *end = const_cast<char*>( s ); 180 179 return result; 181 180 } 182 181 183 float buffer_to_f32( const char* s, char** end )182 float nv::buffer_to_f32( const char* s, char** end ) 184 183 { 185 184 return strtof( s, end ); 186 185 } 187 186 188 double buffer_to_f64( const char* s, char** end )187 double nv::buffer_to_f64( const char* s, char** end ) 189 188 { 190 189 return strtod( s, end );
Note: See TracChangeset
for help on using the changeset viewer.