Changeset 402


Ignore:
Timestamp:
06/13/15 21:51:27 (10 years ago)
Author:
epyon
Message:
  • cleanups of clang warnings (gotta love them all)
  • only nv-core for now (this will take a while for the whole source)
  • mainly C++ casts instead of C-style casts, but also a few bugs fixed!
Location:
trunk
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/base/assert.hh

    r396 r402  
    3939#endif
    4040
     41// TODO: assert levels
    4142#if NV_DEBUG
    4243#define NV_ASSERT(cond, msg) NV_ASSERT_IMPL( (cond) && "assertion failed:" msg )
     44#define NV_DEBUG_ASSERT(cond, msg) NV_ASSERT_IMPL( (cond) && "assertion failed:" msg )
    4345#else 
    44 #define NV_ASSERT(cond, msg)     ((void)0)
     46#define NV_ASSERT(cond, msg) ((void)0)
     47#define NV_DEBUG_ASSERT(cond, msg) ((void)0)
    4548#endif
    4649
  • trunk/nv/base/capi.hh

    r397 r402  
    1212 * This header is temporary
    1313 */
     14
     15// TODO: sanity checking with NV_DEBUG_ASSERT
    1416
    1517#ifndef NV_BASE_CAPI_HH
     
    110112        inline void* nvmemset( void *dest, unsigned char value, size_t count )
    111113        {
    112                 return NV_CAPI_CALL( memset )( dest, (int)value, count );
     114                return NV_CAPI_CALL( memset )( dest, static_cast<int>( value ), count );
    113115        }
    114116
    115117        inline void* nvmemchr( const void *src, unsigned char value, size_t max_count )
    116118        {
    117                 return NV_CAPI_CALL( memchr )( src, (int)value, max_count );
     119                return NV_CAPI_CALL( memchr )( src, static_cast<int>( value ), max_count );
    118120        }
    119121
  • trunk/nv/base/common.hh

    r401 r402  
    77#ifndef NV_BASE_COMMON_HH
    88#define NV_BASE_COMMON_HH
    9 
    10 #define _ITERATOR_DEBUG_LEVEL 0
    119
    1210// NV Library version
     
    199197        using size_t    = decltype( sizeof(0) );
    200198#endif
    201         using ptrdiff_t = decltype((int*)0 - (int*)0);
     199        using ptrdiff_t = decltype( static_cast<int*>(0) - static_cast<int*>(0) );
    202200        using nullptr_t = decltype( nullptr );
    203201       
     
    256254        inline size_t offset_of( T OBJ::*ptr )
    257255        {
    258                 return ( ( size_t )&( ( (OBJ*)0 )->*ptr ) );
     256                return static_cast<size_t>( &( ( static_cast<OBJ*>(0) )->*ptr ) );
    259257        }
    260258
     
    262260        constexpr T narrow_cast( const U& a )
    263261        {
    264                 return static_cast<T>( a & T( -1 ) );
     262                return static_cast<T>( a & static_cast<T>( -1 ) );
    265263        }
    266264
    267265} // namespace nv
    268266
    269 static_assert( nv::size_t( -1 ) > 0,      "size_t is signed!" );
     267static_assert( static_cast<nv::size_t>( -1 ) > 0, "size_t is signed!" );
    270268static_assert( sizeof( nv::size_t ) >= 4, "size_t is smaller than 4 bytes!" );
    271269static_assert( sizeof( nv::sint8 ) == 1, "sint8 size isn't 1 bytes" );
  • trunk/nv/base/rtti_support.hh

    r396 r402  
    4949                constexpr uint64 rtti_hash_impl( char c, const char* remain, uint64 value )
    5050                {
    51                         return c == 0 ? value : rtti_hash_impl( remain[0], remain + 1, (uint64)(uint64)( value ^ (uint64)c ) * rtti_hash_prime );
     51                        return c == 0 ? value : rtti_hash_impl( remain[0], remain + 1, static_cast<uint64>( value ^ static_cast<uint64>(c) ) * rtti_hash_prime );
    5252                }
    5353
     
    6666                static uint64 hash()
    6767                {
    68                         static_assert( NV_TYPE_FAIL(T), "Type not registered!" );
     68                        static_assert( NV_TYPE_FAIL( T ), "Type not registered!" );
    6969                        return 0;
    7070                }
  • trunk/nv/core/library.hh

    r399 r402  
    127127
    128128                /**
    129                  * Destructor.
    130                  *
    131                  * It must not throw any exceptions because of the inheritance
    132                  */
    133                 ~library_error() throw() {}
    134 
    135                 /**
    136129                 * Returns library name
    137130                 */
  • trunk/nv/core/logging.hh

    r399 r402  
    7878                static bool can_log( log_level level )
    7979                {
    80                         return logger_base::is_valid() && (unsigned int)reference().get_level() >= (unsigned int)level;
     80                        return logger_base::is_valid() && static_cast<unsigned int>( reference().get_level() ) >= static_cast<unsigned int>( level );
    8181                }
    8282
     
    8484                {
    8585                        *m_pos = '\0';
    86                         log( level, string_view( m_message, (size_t)( m_pos - m_message ) ) );
     86                        log( level, string_view( m_message, static_cast<size_t>( m_pos - m_message ) ) );
    8787                        m_pos = m_message;
    8888                }
  • trunk/nv/stl/algorithm/fill.hh

    r401 r402  
    3535                void fill_impl( BlockAccessIterator first, BlockAccessIterator last, T value, true_type, block_access_iterator_tag )
    3636                {
    37                         raw_fill( first, last, (unsigned char)value );
     37                        raw_fill( first, last, narrow_cast<unsigned char>( value ) );
    3838                }
    3939
     
    4949                BlockAccessIterator fill_n_impl( BlockAccessIterator first, size_t count, T value, true_type, block_access_iterator_tag )
    5050                {
    51                         return BlockAccessIterator( raw_fill_n( first, count, (unsigned char)value ) );
     51                        return BlockAccessIterator( raw_fill_n( first, count, narrow_cast<unsigned char>( value ) ) );
    5252                }
    5353
  • trunk/nv/stl/algorithm/raw.hh

    r396 r402  
    1919namespace nv
    2020{
     21       
     22        // TODO: better debug macros, both here as well as in nv*funcs
     23        namespace detail
     24        {
     25                template< typename T >
     26                constexpr size_t byte_distance( const T* first, const T* last )
     27                {
     28                        return static_cast<size_t>( reinterpret_cast<uintptr_t>( last ) - reinterpret_cast<uintptr_t>( first ) );
     29                }
     30
     31        }
    2132
    2233        template< typename T >
    2334        T* raw_copy( const T* first, const T* last, T* out )
    2435        {
    25                 return (T*)nvmemcpy( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
     36                NV_DEBUG_ASSERT( last - first > 0, "raw_copy range fail!" );
     37                return static_cast<T*>( nvmemcpy( out, first, detail::byte_distance( first, last ) ) ) + ( last - first );
    2638        }
    2739
     
    2941        T* raw_copy_n( const T* ptr, size_t n, T* out )
    3042        {
    31                 return (T*)nvmemcpy( out, ptr, n * sizeof( T ) ) + n;
     43                return static_cast<T*>( nvmemcpy( out, ptr, n * sizeof( T ) ) ) + n;
    3244        }
    3345
     
    3547        T* raw_alias_copy( const T* first, const T* last, T* out )
    3648        {
    37                 return (T*)nvmemmove( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
     49                NV_DEBUG_ASSERT( last - first > 0, "raw_alias_copy range fail!" );
     50                return static_cast<T*>( nvmemmove( out, first, detail::byte_distance( first, last ) ) ) + ( last - first );
    3851        }
    3952
     
    4154        T* raw_alias_copy_n( const T* ptr, size_t n, T* out )
    4255        {
    43                 return (T*)nvmemmove( out, ptr, n * sizeof( T ) ) + n;
     56                return static_cast<T*>( nvmemmove( out, ptr, n * sizeof( T ) ) ) + n;
    4457        }
    4558
     
    4760        T* raw_zero( T* first, T* last )
    4861        {
    49                 return (T*)nvmemset( first, 0, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
     62                NV_DEBUG_ASSERT( last - first > 0, "raw_zero range fail!" );
     63                return static_cast<T*>( nvmemset( first, 0, detail::byte_distance( first, last ) ) ) + ( last - first );
    5064        }
    5165
     
    5367        T* raw_zero_n( T* ptr, size_t n )
    5468        {
    55                 return (T*)nvmemset( ptr, 0, n * sizeof( T ) ) + n;
     69                return static_cast<T*>( nvmemset( ptr, 0, n * sizeof( T ) ) ) + n;
    5670        }
    5771
     
    5973        T* raw_fill( T* first, T* last, unsigned char value )
    6074        {
    61                 return (T*)nvmemset( first, value, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) + ( last - first );
     75                NV_DEBUG_ASSERT( last - first > 0, "raw_fill range fail!" );
     76                return static_cast<T*>( nvmemset( first, value, detail::byte_distance( first, last ) ) ) + ( last - first );
    6277        }
    6378
     
    6580        T* raw_fill_n( T* ptr, size_t n, unsigned char value )
    6681        {
    67                 return (T*)nvmemset( ptr, value, n * sizeof( T ) ) + n;
     82                return static_cast<T*>( nvmemset( ptr, value, n * sizeof( T ) ) ) + n;
    6883        }
    6984
  • trunk/nv/stl/container/hash_table.hh

    r401 r402  
    5656                public:
    5757                        constexpr iterator_base() : m_node( nullptr ) {}
    58                         constexpr iterator_base( const iterator_base& it ) : m_node( it.m_node ) {}
    5958                        const entry_type* entry() const { return m_node;  }
    6059                        reference operator*() const { return m_node->value; }
     
    7271                        typedef iterator_base< IsConst > base_type;
    7372
    74                         constexpr node_iterator() : base_type( nullptr ) {}
    75                         constexpr node_iterator( const node_iterator& it ) : base_type( it.m_node ) {}
    76 
     73                        constexpr node_iterator() = default;
    7774                        template < bool B, typename = enable_if_t< IsConst && !B > >
    78                         constexpr node_iterator( const node_iterator< B >& it )
    79                                 : base_type( it.m_node )
    80                         {
    81                         }
     75                        constexpr node_iterator( const node_iterator< B >& it ) : base_type( it.m_node ) {}
    8276
    8377                        node_iterator& operator++() { increment(); return *this; }
     
    236230                inline size_type max_size() const { return 2147483647; }
    237231                inline size_type max_bucket_count() const { return 2147483647; }
    238                 inline float load_factor() const { return (float)m_element_count / (float)m_bucket_count; }
     232                inline float load_factor() const { return static_cast<float>( m_element_count ) / static_cast<float>( m_bucket_count ); }
    239233                inline float max_load_factor() const { return m_max_load_factor; }
    240234                inline void max_load_factor( float ml ) { m_max_load_factor = ml; }
     
    312306                void zero()
    313307                {
    314                         m_buckets       = (node_type**)&g_hash_table_empty[0];
     308                        m_buckets       = reinterpret_cast<node_type**>( &g_hash_table_empty[0] );
    315309                        m_bucket_count  = 1;
    316310                        m_element_count = 0;
     
    343337                {
    344338                        NV_ASSERT( new_count > 1, "allocate_buckets fail!" );
    345                         node_type** buckets = ( node_type** )nvmalloc( ( new_count + 1 ) * sizeof( node_type* ) );
     339                        node_type** buckets = reinterpret_cast<node_type**>( nvmalloc( ( new_count + 1 ) * sizeof( node_type* ) ) );
    346340                        nvmemset( buckets, 0, ( new_count + 1 ) * sizeof( node_type* ) );
    347                         buckets[ new_count ] = reinterpret_cast<node_type*>( (uintptr_t)~0 ); // sentinel
     341                        buckets[ new_count ] = reinterpret_cast<node_type*>( uintptr_t(~0) ); // sentinel
    348342                        return buckets;
    349343                }
     
    356350                node_type* alloc_node()
    357351                {
    358                         return (node_type*)nvmalloc( sizeof( node_type ) );
     352                        return static_cast<node_type*>( nvmalloc( sizeof( node_type ) ) );
    359353                }
    360354
  • trunk/nv/stl/container/hash_table_policy.hh

    r401 r402  
    279279                static uint32 get_bucket_count( uint32 element_count, float load_factor )
    280280                {
    281                         uint32 min_count = (uint32)( element_count / load_factor );
     281                        uint32 min_count = static_cast<uint32>( element_count / load_factor );
    282282                        return get_prime_larger_or_equal_to( min_count );
    283283                }
    284284                static uint32 is_rehash_required( uint32 bucket_count, uint32 element_count, float load_factor )
    285285                {
    286                         uint32 min_count = (uint32)( element_count / load_factor );
     286                        uint32 min_count = static_cast<uint32>( element_count / load_factor );
    287287                        if ( bucket_count < 2 || min_count > bucket_count )
    288288                        {
  • trunk/nv/stl/functional/hash.hh

    r401 r402  
    6161                        static constexpr H str_hash_impl( char c, const char* remain, H value )
    6262                        {
    63                                 return c == 0 ? value : str_hash_impl( remain[0], remain + 1, (H)(H)( value ^ (H)c ) * hash_prime );
     63                                return c == 0 ? value : str_hash_impl( remain[0], remain + 1, static_cast<H>( value ^ static_cast<H>( c ) ) * hash_prime );
    6464                        }
    6565                        static constexpr H hash_impl( const char* current, size_t remain, H value )
    6666                        {
    67                                 return remain == 0 ? value : hash_impl( current + 1, remain - 1, (H)(H)( value ^ (H)(current[0]) ) * hash_prime );
     67                                return remain == 0 ? value : hash_impl( current + 1, remain - 1, static_cast<H>( value ^ static_cast<H>( current[0] ) ) * hash_prime );
    6868                        }
    6969                };
     
    119119                {
    120120                        return value == 0.0f ? detail::fnv_hash<H>( &value, 1 ) : 0;
    121                 };
     121                }
    122122                inline H operator()( float value ) const { return get( value ); }
    123123        };
     
    130130                {
    131131                        return value == 0.0f ? detail::fnv_hash<H>( &value, 1 ) : 0;
    132                 };
     132                }
    133133                inline H operator()( float value ) const { return get( value ); }
    134134        };
  • trunk/nv/stl/limits.hh

    r395 r402  
    3636                static constexpr int sc_bit = sizeof( signed char ) * 8;
    3737                static constexpr char c_min = ( char( 0 ) < char( -1 ) ? 0 : -128 );
    38                 static constexpr char c_max = ( char( 0 ) < char( -1 ) ? 255 : 127 );
     38                static constexpr char c_max = ( char( 0 ) < char( -1 ) ? narrow_cast<char>( 255 ) : 127 );
    3939                static constexpr int c_bit = sizeof( char ) * 8;
    4040                static constexpr unsigned short us_min = 0;
  • trunk/nv/stl/memory.hh

    r401 r402  
    163163        }
    164164
    165         template <typename TYPE>
     165        template < typename T >
    166166        void raw_destroy_object( void* object )
    167167        {
    168                 ( (TYPE*)object )->TYPE::~TYPE();
     168                static_cast<T*>( object )->T::~T();
    169169        }
    170170
     
    183183                        ForwardIterator it( first );
    184184                        for ( ; it != last; ++it )
    185                                 ::new( (void*)&*it ) value_type( value );
     185                                ::new( static_cast<void*>( addressof( *it ) ) ) value_type( value );
    186186                }
    187187
     
    198198                        ForwardIterator it( first );
    199199                        for ( ; count > 0; --count, ++it )
    200                                 ::new ( (void*)&*it ) value_type( value );
     200                                ::new ( static_cast<void*>( addressof( *it ) ) ) value_type( value );
    201201                        return it;
    202202                }
     
    214214                        ForwardIterator it( first );
    215215                        for ( ; it != last; ++it )
    216                                 ::new( (void*)&*it ) value_type;
     216                                ::new( static_cast<void*>( addressof( *it ) ) ) value_type;
    217217                }
    218218
     
    229229                        ForwardIterator it( first );
    230230                        for ( ; count > 0; --count, ++it )
    231                                 ::new( (void*)&*it ) value_type;
     231                                ::new( static_cast<void*>( addressof( *it ) ) ) value_type;
    232232                }
    233233
     
    323323                ForwardIterator it( first );
    324324                for ( ; it != last; ++it )
    325                         ::new( (void*)&*it ) value_type( forward<Args>( params )... );
     325                        ::new( static_cast<void*>( addressof( *it ) ) ) value_type( forward<Args>( params )... );
    326326        }
    327327
  • trunk/nv/stl/string.hh

    r401 r402  
    168168                size_type reverse_distance( ReverseIterator first, ReverseIterator last ) const
    169169                {
    170                         return this->size() - 1 - (size_t)nv::distance( first, last );
     170                        return this->size() - 1 - static_cast<size_t>( nv::distance( first, last ) );
    171171                }
    172172        };
     
    252252        {
    253253                size_type this_size = this->size();
    254                 int cmp = nvmemcmp( this->data(), rhs.data(), ( nv::min )( this_size, rhs.size() ) );
     254                int cmp = nvmemcmp( this->data(), rhs.data(), nv::min( this_size, rhs.size() ) );
    255255                return cmp != 0 ? cmp : ( this_size == rhs.size() ? 0 : this_size < rhs.size() ? -1 : 1 );
    256256        }
     
    282282        {
    283283                if ( pos >= this->size() ) return npos;
    284                 const_iterator it = nv::find_if( this->cbegin() + (difference_type)pos, this->cend(), [=] ( value_type val ) { return val == c; } );
    285                 return it == this->cend() ? npos : (size_type)nv::distance( this->cbegin(), it );
     284                const_iterator it = nv::find_if( this->cbegin() + static_cast<difference_type>( pos ), this->cend(), [=] ( value_type val ) { return val == c; } );
     285                return it == this->cend() ? npos : static_cast<size_type>( nv::distance( this->cbegin(), it ) );
    286286        }
    287287        template < typename Storage >
     
    289289        {
    290290                if ( pos >= this->size() ) return npos;
    291                 const_iterator it = nv::search( this->cbegin() + (difference_type)pos, this->cend(), s.cbegin(), s.cend() );
    292                 return it == this->cend() ? npos : (size_type)nv::distance( this->cbegin(), it );
     291                const_iterator it = nv::search( this->cbegin() + static_cast<difference_type>( pos ), this->cend(), s.cbegin(), s.cend() );
     292                return it == this->cend() ? npos : static_cast<size_type>( nv::distance( this->cbegin(), it ) );
    293293        }
    294294
     
    297297        {
    298298                if ( pos >= this->size() ) return npos;
    299                 const_reverse_iterator it = nv::find_if( this->crbegin() + (difference_type)pos, this->crend(), [=] ( value_type val ) { return val == c; } );
     299                const_reverse_iterator it = nv::find_if( this->crbegin() + static_cast<difference_type>( pos ), this->crend(), [=] ( value_type val ) { return val == c; } );
    300300                return it == this->crend() ? npos : this->reverse_distance( this->crbegin(), it );
    301301        }
     
    304304        {
    305305                if ( pos >= this->size() ) return npos;
    306                 const_reverse_iterator it = nv::search( this->crbegin() + (difference_type)pos, this->crend(), s.crbegin(), s.crend() );
     306                const_reverse_iterator it = nv::search( this->crbegin() + static_cast<difference_type>( pos ), this->crend(), s.crbegin(), s.crend() );
    307307                return it == this->crend() ? npos : this->reverse_distance( this->crbegin(), it );
    308308        }
     
    317317        {
    318318                const_iterator it = nv::find_first_of( this->cbegin(), this->cend(), s.cbegin(), s.cend() );
    319                 return it == this->cend() ? npos : (size_type)nv::distance( this->cbegin(), it );
     319                return it == this->cend() ? npos : static_cast<size_type>( nv::distance( this->cbegin(), it ) );
    320320        }
    321321
     
    337337                for ( const_iterator it = this->cbegin(); it != this->cend(); ++it )
    338338                        if ( c != *it )
    339                         return (size_type)distance( this->cbegin(), it );
     339                        return static_cast<size_type>( nv::distance( this->cbegin(), it ) );
    340340                return npos;
    341341        }
     
    344344        {
    345345                for ( const_iterator it = this->cbegin(); it != this->cend(); ++it )
    346                         if ( 0 == nvmemchr( s.data(), (uchar8)*it, s.size() ) )
    347                         return (size_type)distance( this->cbegin(), it );
     346                        if ( 0 == nvmemchr( s.data(), static_cast<uchar8>( *it ), s.size() ) )
     347                        return static_cast<size_type>( nv::distance( this->cbegin(), it ) );
    348348                return npos;
    349349        }
     
    361361        {
    362362                for ( const_reverse_iterator it = this->crbegin(); it != this->crend(); ++it )
    363                         if ( 0 == nvmemchr( s.data(), (uchar8)*it, s.size() ) )
     363                        if ( 0 == nvmemchr( s.data(), static_cast<uchar8>( *it ), s.size() ) )
    364364                        return this->reverse_distance( this->crbegin(), it );
    365365                return npos;
     
    434434#undef NV_STRING_REF_CAST_OPERATORS
    435435
    436 size_t sint32_to_buffer( sint32 n, char* str );
    437 size_t sint64_to_buffer( sint64 n, char* str );
    438 size_t uint32_to_buffer( uint32 n, char* str );
    439 size_t uint64_to_buffer( uint64 n, char* str );
    440 size_t f32_to_buffer( f32 n, char* str );
    441 size_t f64_to_buffer( f64 n, char* str );
     436        size_t sint32_to_buffer( sint32 n, char* str );
     437        size_t sint64_to_buffer( sint64 n, char* str );
     438        size_t uint32_to_buffer( uint32 n, char* str );
     439        size_t uint64_to_buffer( uint64 n, char* str );
     440        size_t f32_to_buffer( f32 n, char* str );
     441        size_t f64_to_buffer( f64 n, char* str );
     442        sint32 buffer_to_sint32( const char* str, char** end );
     443        sint64 buffer_to_sint64( const char* s, char** end );
     444        uint32 buffer_to_uint32( const char* s, char** end );
     445        uint64 buffer_to_uint64( const char* s, char** end );
     446        float buffer_to_f32( const char* s, char** end );
     447        double buffer_to_f64( const char* s, char** end );
    442448
    443449        // const string is movable but not copyable
  • trunk/nv/stl/type_traits.hh

    r395 r402  
    1111 */
    1212
    13  // TODO : "......" function match version?
     13 // TODO : "..., ..." function match version?
    1414// TODO : the following symbols are unimplemented:
    1515//  * is_constructible, is_trivially_constructible, is_nothrow_constructible
  • trunk/nv/stl/type_traits/common.hh

    r401 r402  
    182182        constexpr typename remove_reference<T>::type&& move( T&& arg ) noexcept
    183183        {
    184                 return ( ( typename remove_reference<T>::type&& )arg );
     184                return static_cast<typename remove_reference<T>::type&&>( arg );
    185185        }
    186186
  • trunk/nv/stl/type_traits/function.hh

    r395 r402  
    1010 * @brief type traits - function traits
    1111 */
    12 // TODO: remove_cv? call traits? support "......"?
     12// TODO: remove_cv? call traits?
    1313
    1414#ifndef NV_STL_TRAITS_FUNCTION_HH
     
    114114                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( CALLDECL C::* )( Args... ) const > { typedef R result_type; }; \
    115115                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( CALLDECL C::* )( Args... ) volatile > { typedef R result_type; }; \
    116                 template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( CALLDECL C::* )( Args... ) const volatile > { typedef R result_type; };
    117 
     116                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( CALLDECL C::* )( Args... ) const volatile > { typedef R result_type; }; \
     117               
     118//NV_EMIT_WEAK_RESULT_TYPE_CALLDECL()
    118119NV_EMIT_WEAK_RESULT_TYPE_CALLDECL( __cdecl )
    119120NV_EMIT_WEAK_RESULT_TYPE_CALLDECL( __fastcall )
    120121NV_EMIT_WEAK_RESULT_TYPE_CALLDECL( __vectorcall )
     122template < typename R, typename... Args > struct weak_result_type_impl< R __cdecl ( Args..., ... ) > { typedef R result_type; }; \
     123template < typename R, typename... Args > struct weak_result_type_impl< R( __cdecl & )( Args..., ... ) > { typedef R result_type; }; \
     124template < typename R, typename... Args > struct weak_result_type_impl< R( __cdecl * )( Args..., ... ) > { typedef R result_type; }; \
     125template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( __cdecl C::* )( Args..., ... ) > { typedef R result_type; }; \
     126template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( __cdecl C::* )( Args..., ... ) const > { typedef R result_type; }; \
     127template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( __cdecl C::* )( Args..., ... ) volatile > { typedef R result_type; }; \
     128template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( __cdecl C::* )( Args..., ... ) const volatile > { typedef R result_type; }; \
     129
    121130#       if NV_ARCHITECTURE == NV_32BIT
    122131NV_EMIT_WEAK_RESULT_TYPE_CALLDECL( __stdcall )
    123132template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( __thiscall C::* )( Args... ) > { typedef R result_type; };
    124 template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( __thiscall C::* )( Args... ) const > { typedef R result_type; }; \
    125 template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( __thiscall C::* )( Args... ) volatile > { typedef R result_type; }; \
     133template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( __thiscall C::* )( Args... ) const > { typedef R result_type; };
     134template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( __thiscall C::* )( Args... ) volatile > { typedef R result_type; };
    126135template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( __thiscall C::* )( Args... ) const volatile > { typedef R result_type; };
    127136#       endif
     
    129138#else
    130139                template < typename R, typename... Args > struct weak_result_type_impl< R( Args... ) > { typedef R result_type; };
    131                 template < typename R, typename... Args > struct weak_result_type_impl< R( Args...... ) > { typedef R result_type; };
     140                template < typename R, typename... Args > struct weak_result_type_impl< R( Args..., ... ) > { typedef R result_type; };
    132141                template < typename R, typename... Args > struct weak_result_type_impl< R( Args... ) const > { typedef R result_type; };
    133                 template < typename R, typename... Args > struct weak_result_type_impl< R( Args...... ) const > { typedef R result_type; };
     142                template < typename R, typename... Args > struct weak_result_type_impl< R( Args..., ... ) const > { typedef R result_type; };
    134143                template < typename R, typename... Args > struct weak_result_type_impl< R( Args... ) volatile > { typedef R result_type; };
    135                 template < typename R, typename... Args > struct weak_result_type_impl< R( Args...... ) volatile > { typedef R result_type; };
     144                template < typename R, typename... Args > struct weak_result_type_impl< R( Args..., ... ) volatile > { typedef R result_type; };
    136145                template < typename R, typename... Args > struct weak_result_type_impl< R( Args... ) const volatile > { typedef R result_type; };
    137                 template < typename R, typename... Args > struct weak_result_type_impl< R( Args...... ) const volatile > { typedef R result_type; };
     146                template < typename R, typename... Args > struct weak_result_type_impl< R( Args..., ... ) const volatile > { typedef R result_type; };
    138147                template < typename R, typename... Args > struct weak_result_type_impl< R( & )( Args... ) > { typedef R result_type; };
    139                 template < typename R, typename... Args > struct weak_result_type_impl< R( & )( Args...... ) > { typedef R result_type; };
     148                template < typename R, typename... Args > struct weak_result_type_impl< R( & )( Args..., ... ) > { typedef R result_type; };
    140149                template < typename R, typename... Args > struct weak_result_type_impl< R( * )( Args... ) > { typedef R result_type; };
    141                 template < typename R, typename... Args > struct weak_result_type_impl< R( * )( Args...... ) > { typedef R result_type; };
     150                template < typename R, typename... Args > struct weak_result_type_impl< R( * )( Args..., ... ) > { typedef R result_type; };
    142151                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args... ) > { typedef R result_type; };
    143                 template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args...... ) > { typedef R result_type; };
     152                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args..., ... ) > { typedef R result_type; };
    144153                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args... ) const > { typedef R result_type; };
    145                 template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args...... ) const > { typedef R result_type; };
     154                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args..., ... ) const > { typedef R result_type; };
    146155                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args... ) volatile > { typedef R result_type; };
    147                 template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args...... ) volatile > { typedef R result_type; };
     156                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args..., ... ) volatile > { typedef R result_type; };
    148157                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args... ) const volatile > { typedef R result_type; };
    149                 template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args...... ) const volatile > { typedef R result_type; };
     158                template < typename R, typename C, typename... Args > struct weak_result_type_impl< R( C::* )( Args..., ... ) const volatile > { typedef R result_type; };
    150159#endif
    151160        }
  • trunk/nv/stl/type_traits/primary.hh

    r395 r402  
    6060        // is_function_pointer / is_member_function pointer - extension
    6161        // TODO: sanity check - this is very different - http://en.cppreference.com/w/cpp/types/is_function
    62         // TODO: "......" function match version?
     62        // TODO: "..., ..." function match version?
    6363        // TODO: call conventions really needed?
    6464
  • trunk/nv/stl/type_traits/properties.hh

    r400 r402  
    160160                template < typename R, typename... Args >
    161161                struct is_referenceable < R( Args... ) > : true_type {};
    162 #if NV_COMPILER != NV_MSVC
    163162                template < typename R, typename... Args >
    164                 struct is_referenceable < R( Args...... ) > : true_type {};
    165 #endif
     163                struct is_referenceable < R( Args..., ... ) > : true_type {};
    166164
    167165                template < typename To, typename From >
     
    293291                        static size_two test( ... );
    294292                public:
    295                         static constexpr bool value = sizeof( test<T>( 0 ) ) == 1;
     293                        static constexpr bool value = sizeof( test( static_cast<T*>( nullptr ) ) ) == 1;
    296294                };
    297295        }
  • trunk/src/core/library.cc

    r399 r402  
    1111#   include <windows.h>
    1212#   define NV_LIB_EXT ".dll"
    13 #   define NV_LIB_HANDLE HMODULE
    14 #   define NV_LIB_OPEN( name ) LoadLibraryEx( name, NULL, LOAD_WITH_ALTERED_SEARCH_PATH )
    15 #   define NV_LIB_GET( handle, name ) GetProcAddress( handle, name )
    16 #   define NV_LIB_CLOSE( name ) !FreeLibrary( name )
     13#   define NV_LIB_OPEN( name ) static_cast<void*>( LoadLibraryEx( name, NULL, LOAD_WITH_ALTERED_SEARCH_PATH ) )
     14#   define NV_LIB_GET( handle, name ) reinterpret_cast<void*>( GetProcAddress( static_cast<HMODULE>( handle ), name ) )
     15#   define NV_LIB_CLOSE( handle ) ( FreeLibrary( static_cast<HMODULE>( handle ) ) != 0 )
    1716#elif NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE
    1817#   include <dlfcn.h>
    1918#   define NV_LIB_EXT ".so"
    20 #   define NV_LIB_HANDLE void*
    2119#   define NV_LIB_OPEN( name ) dlopen( name, RTLD_LAZY | RTLD_GLOBAL)
    22 #   define NV_LIB_GET( handle, name ) dlsym( handle, name )
    23 #   define NV_LIB_CLOSE( name ) dlclose( name )
     20#   define NV_LIB_GET( handle, name ) dlsym( static_cast<void*>( handle ), name )
     21#   define NV_LIB_CLOSE( handle ) ( dlclose( static_cast<void*>( handle ) ) == 0 )
    2422#elif NV_PLATFORM == NV_APPLE
    2523#   include "macUtils.h"
    2624#   include <dlfcn.h>
    2725#   define NV_LIB_EXT ".dylib"
    28 #   define NV_LIB_HANDLE CFBundleRef
    2926#   define NV_LIB_OPEN( name ) mac_loadExeBundle( name )
    3027#   define NV_LIB_GET( handle, name ) mac_getBundleSym( handle, name )
    31 #   define NV_LIB_CLOSE( name ) mac_unloadExeBundle( name )
     28#   define NV_LIB_CLOSE( handle ) ( mac_unloadExeBundle( handle ) == 0 )
    3229#endif
    3330
     
    8380    }
    8481
    85     m_handle = (void*)NV_LIB_OPEN( name.c_str() );
     82    m_handle = NV_LIB_OPEN( name.c_str() );
    8683
    8784    if ( m_handle == NULL )
     
    9693void* library::get( string_view symbol )
    9794{
    98         void* result = (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.data() );
     95        void* result = NV_LIB_GET( m_handle, symbol.data() );
    9996    if ( !result )
    10097    {
     
    106103void* nv::library::try_get( string_view symbol )
    107104{
    108         return (void*) NV_LIB_GET( (NV_LIB_HANDLE) m_handle, symbol.data() );
     105        return NV_LIB_GET( m_handle, symbol.data() );
    109106}
    110107
     
    116113void library::close()
    117114{
    118     if ( NV_LIB_CLOSE( (NV_LIB_HANDLE)m_handle ) )
     115    if ( ! NV_LIB_CLOSE( m_handle ) )
    119116    {
    120117        NV_LOG_ERROR( "library : can't close library '", m_name, "'!" );
    121118    }
    122     m_handle = NULL;
     119    m_handle = nullptr;
    123120}
    124121
    125122library::~library()
    126123{
    127     if ( m_handle != NULL )
     124    if ( m_handle != nullptr )
    128125    {
    129126        close();
     
    135132#if NV_PLATFORM == NV_WINDOWS
    136133    // We do hate WinAPI for code like this, don't we?
    137     LPTSTR buffer = NULL;
     134    LPTSTR buffer = nullptr;
    138135    FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
    139         NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &buffer, 0, NULL );
    140     std::string msg( (char*)buffer );
     136        NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPTSTR>( &buffer ), 0, NULL );
     137    std::string msg( reinterpret_cast<char*>( buffer ) );
    141138    LocalFree( buffer );
    142139    return msg;
    143140#elif NV_PLATFORM == NV_LINUX || NV_PLATFORM == NV_APPLE
    144     return string(dlerror());
     141    return std::string( dlerror() );
    145142#else
    146     return string("");
     143    return std::string("");
    147144#endif
    148145}
  • trunk/src/core/logger.cc

    r399 r402  
    8989        for ( auto& sink_info : m_log_sinks )
    9090        {
    91                 if ( sink_info.sink && (sink_info.level >= (uint32)level) )
     91                if ( sink_info.sink && (sink_info.level >= static_cast<uint32>( level ) ) )
    9292                {
    9393                        // log and iterate
     
    106106                {
    107107                        sink_info.sink  = sink;
    108                         sink_info.level = (uint32)level;
     108                        sink_info.level = static_cast<uint32>( level );
    109109                        return;
    110110                }
     
    194194        //if ( m_flush ) FlushFileBuffers( m_handle );
    195195#else
    196         fwrite( stamp, ssize, 1, (FILE*)m_handle );
    197         fwrite( " [", 2, 1, (FILE*)m_handle );
    198         fwrite( NV_LOG_LEVEL_NAME_PAD( level ), 8, 1, (FILE*)m_handle );
    199         fwrite( "] ", 2, 1, (FILE*)m_handle );
    200         fwrite( message.data(), message.size(), 1, (FILE*)m_handle );
    201         fwrite( "\n", 1, 1, (FILE*)m_handle );
    202         if ( m_flush ) fflush( (FILE*)m_handle );
     196        FILE* file = static_cast<FILE*>( m_handle );
     197        fwrite( stamp, ssize, 1, file );
     198        fwrite( " [", 2, 1, file );
     199        fwrite( NV_LOG_LEVEL_NAME_PAD( level ), 8, 1, file );
     200        fwrite( "] ", 2, 1, file );
     201        fwrite( message.data(), message.size(), 1, file );
     202        fwrite( "\n", 1, 1, file );
     203        if ( m_flush ) fflush( file );
    203204#endif
    204205}
     
    226227        CloseHandle( m_handle );
    227228#else
    228         fclose( (FILE*) m_handle );
     229        fclose( static_cast<FILE*>( m_handle ) );
    229230#endif
    230231}
     
    244245{
    245246        uint32 ms = get_system_ms();
    246         unsigned int secs = (unsigned int)(ms / 1000);
    247         unsigned int mm   = (unsigned int)( ms * 100 / 1000 ) % 100;
    248         unsigned int h    = (unsigned int)(secs / (60*60));
    249         unsigned int m    = (unsigned int)(secs / 60) % 60;
     247        unsigned int secs = static_cast<unsigned int>( ms / 1000 );
     248        unsigned int mm   = static_cast<unsigned int>( ms * 100 / 1000 ) % 100;
     249        unsigned int h    = static_cast<unsigned int>( secs / (60*60) );
     250        unsigned int m    = static_cast<unsigned int>( secs / 60 ) % 60;
    250251        unsigned int s    = secs % 60;
    251252#if NV_COMPILER == NV_MSVC
  • trunk/src/core/profiler.cc

    r399 r402  
    124124                if ( c->m_calls > 0 )
    125125                {
    126                         f64 pparent = ( (f64)c->m_total_time_us / (f64)c->m_parent->m_total_time_us ) * 100.f;
     126                        f64 ftotal_time_us = static_cast<f64>( c->m_total_time_us );
     127                        f64 pparent = ( ftotal_time_us / static_cast<f64>( c->m_parent->m_total_time_us ) ) * 100.f;
    127128                        uint32 calls       = c->m_calls;
    128                         f64 total_ms = c->m_total_time_us / 1000.f;
    129                         f64 avg_ms = ( (f64)c->m_total_time_us / (f64)c->m_calls ) / 1000.f;
     129                        f64 total_ms = ftotal_time_us / 1000.f;
     130                        f64 avg_ms = ( ftotal_time_us / static_cast<f64>( c->m_calls ) ) / 1000.f;
    130131                        if ( indent > 0 ) nvmemset( buffer, '-', indent );
    131132                        snprintf( buffer + indent, 128 - indent, "%*.*s %6.2f %6d %9.2f %6.2f", indent - 23, 23 - indent,
  • trunk/src/core/random.cc

    r395 r402  
    1919random::seed_type random::randomize()
    2020{
    21         std::mt19937& rng = *(( std::mt19937* )m_data);
     21        std::mt19937& rng = *( reinterpret_cast< std::mt19937* >( m_data ) );
    2222        seed_type seed = randomized_seed();
    2323        rng.seed( seed );
     
    2727void random::set_seed( random::seed_type seed /*= 0 */ )
    2828{
    29         std::mt19937& rng = *( ( std::mt19937* )m_data );
     29        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    3030        rng.seed( seed == 0 ? randomized_seed() : seed );
    3131}
     
    3939random::result_type random::rand()
    4040{
    41         std::mt19937& rng = *( ( std::mt19937* )m_data );
     41        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    4242        return rng();
    4343}
     
    4545sint32 random::srand( sint32 val )
    4646{
    47         std::mt19937& rng = *( ( std::mt19937* )m_data );
     47        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    4848        std::uniform_int_distribution<sint32> dist( 0, val - 1 );
    4949        return dist( rng );
     
    5252uint32 random::urand( uint32 val )
    5353{
    54         std::mt19937& rng = *( ( std::mt19937* )m_data );
     54        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    5555        std::uniform_int_distribution<uint32> dist( 0, val - 1 );
    5656        return dist( rng );
     
    5959f32 random::frand( f32 val )
    6060{
    61         std::mt19937& rng = *( ( std::mt19937* )m_data );
     61        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    6262        std::uniform_real_distribution<f32> dist( 0, val );
    6363        return dist( rng );
     
    6666sint32 random::srange( sint32 min, sint32 max )
    6767{
    68         std::mt19937& rng = *( ( std::mt19937* )m_data );
     68        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    6969        std::uniform_int_distribution<sint32> dist( min, max );
    7070        return dist( rng );
     
    7373uint32 random::urange( uint32 min, uint32 max )
    7474{
    75         std::mt19937& rng = *( ( std::mt19937* )m_data );
     75        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    7676        std::uniform_int_distribution<uint32> dist( min, max );
    7777        return dist( rng );
     
    8080f32 random::frange( f32 min, f32 max )
    8181{
    82         std::mt19937& rng = *( ( std::mt19937* )m_data );
     82        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    8383        std::uniform_real_distribution<f32> dist( min, max );
    8484        return dist( rng );
     
    8787uint32 random::dice( uint32 count, uint32 sides )
    8888{
    89         std::mt19937& rng = *( ( std::mt19937* )m_data );
     89        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    9090        std::uniform_int_distribution<uint32> dist( 1, sides );
    9191        uint32 result = 0;
     
    106106nv::vec2 nv::random::precise_unit_vec2()
    107107{
    108         std::mt19937& rng = *( ( std::mt19937* )m_data );
     108        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    109109        std::uniform_real_distribution<f32> dist( 0, glm::pi<float>() * 2.f );
    110110        float angle = dist( rng );
     
    114114nv::vec3 nv::random::precise_unit_vec3()
    115115{
    116         std::mt19937& rng = *( ( std::mt19937* )m_data );
     116        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    117117        std::uniform_real_distribution<f32> dist11( -1.0f, 1.0f );
    118118        std::uniform_real_distribution<f32> dist02pi( 0.0f, 2*glm::pi<float>() );
     
    129129nv::vec2 nv::random::fast_disk_point()
    130130{
    131         std::mt19937& rng = *( ( std::mt19937* )m_data );
     131        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    132132        std::uniform_real_distribution<f32> dist( 0.0f, 1.0f );
    133133        float r1 = dist( rng );
     
    140140nv::vec2 nv::random::precise_disk_point()
    141141{
    142         std::mt19937& rng = *( ( std::mt19937* )m_data );
     142        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    143143        std::uniform_real_distribution<f32> unit( 0.0f, 1.0f );
    144144        std::uniform_real_distribution<f32> angle( 0.0f, glm::pi<float>() );
     
    150150nv::vec3 nv::random::fast_sphere_point()
    151151{
    152         std::mt19937& rng = *( ( std::mt19937* )m_data );
     152        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    153153        std::uniform_real_distribution<f32> dist01( 0.0f, 1.0f );
    154154        std::uniform_real_distribution<f32> dist11( -1.0f, 1.0f );
     
    168168nv::vec3 nv::random::precise_sphere_point()
    169169{
    170         std::mt19937& rng = *( ( std::mt19937* )m_data );
     170        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    171171        std::uniform_real_distribution<f32> dist01( 0.0f, 1.0f );
    172172        std::uniform_real_distribution<f32> dist11( -1.0f, 1.0f );
     
    185185nv::vec2 nv::random::precise_ellipse_point( const vec2& radii )
    186186{
    187         std::mt19937& rng = *( ( std::mt19937* )m_data );
     187        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    188188        std::uniform_real_distribution<f32> distx( -radii.x, radii.x );
    189189        std::uniform_real_distribution<f32> disty( -radii.y, radii.y );
     
    204204nv::vec3 nv::random::precise_ellipsoid_point( const vec3& radii )
    205205{
    206         std::mt19937& rng = *( ( std::mt19937* )m_data );
     206        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    207207        std::uniform_real_distribution<f32> distx( -radii.x, radii.x );
    208208        std::uniform_real_distribution<f32> disty( -radii.y, radii.y );
     
    225225nv::vec2 nv::random::fast_hollow_disk_point( float iradius, float oradius )
    226226{
    227         std::mt19937& rng = *( ( std::mt19937* )m_data );
     227        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    228228        float idist2 = iradius * iradius;
    229229        float odist2 = oradius * oradius;
     
    239239nv::vec3 nv::random::fast_hollow_sphere_point( float iradius, float oradius )
    240240{
    241         std::mt19937& rng = *( ( std::mt19937* )m_data );
     241        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    242242        float idist3 = iradius * iradius * iradius;
    243243        float odist3 = oradius * oradius * oradius;
     
    254254nv::vec2 nv::random::fast_hollow_ellipse_point( const vec2& iradii, const vec2& oradii )
    255255{
    256         std::mt19937& rng = *( ( std::mt19937* )m_data );
     256        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    257257        vec2 iradii2 = iradii * iradii;
    258258        vec2 opoint     = ellipse_edge( oradii );
     
    275275nv::vec3 nv::random::fast_hollow_ellipsoid_point( const vec3& iradii, const vec3& oradii )
    276276{
    277         std::mt19937& rng = *( ( std::mt19937* )m_data );
     277        std::mt19937& rng = *( reinterpret_cast<std::mt19937*>( m_data ) );
    278278        vec3 iradii2 = iradii * iradii;
    279279        vec3 opoint     = ellipsoid_edge( oradii );
  • trunk/src/core/time.cc

    r401 r402  
    8585nv::uint32 nv::get_cpu_ms()
    8686{
    87         return (uint32)( (f32)( clock() - zero_timer.clock_zero ) / ( (f32)CLOCKS_PER_SEC / 1000.0 ) ) ;
     87        return static_cast<uint32>( static_cast<f32>( clock() - zero_timer.clock_zero ) / ( static_cast<f32>(CLOCKS_PER_SEC) / 1000.0f ) ) ;
    8888}
    8989
    9090nv::uint64 nv::get_cpu_us()
    9191{
    92         return (uint64)( (f32)( clock() - zero_timer.clock_zero ) / ( (f32)CLOCKS_PER_SEC / 1000000.0 ) ) ;
     92        return static_cast<uint64>( static_cast<f32>( clock() - zero_timer.clock_zero ) / ( static_cast<f32>(CLOCKS_PER_SEC) / 1000000.0f ) ) ;
    9393}
    9494
     
    9999        QueryPerformanceCounter(&now);
    100100        LONGLONG result = now.QuadPart - zero_timer.query_zero.QuadPart;
    101         return (uint32) (1000.0 * result / (double) zero_timer.frequency.QuadPart);
     101        return static_cast<uint32>(1000.0 * result / static_cast<f64>( zero_timer.frequency.QuadPart ) );
    102102#else
    103103        struct timeval now;
    104104        gettimeofday(&now, NULL);
    105         return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 );
     105        return static_cast<uint32>( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000+(now.tv_usec-zero_timer.timeval_zero.tv_usec)/1000 );
    106106#endif
    107107}
     
    113113        QueryPerformanceCounter(&now);
    114114        LONGLONG result = now.QuadPart - zero_timer.query_zero.QuadPart;
    115         return (uint64) (1000000.0 * result / (double) zero_timer.frequency.QuadPart);
     115        return static_cast<uint64>(1000000.0 * result / static_cast<f64>( zero_timer.frequency.QuadPart ) );
    116116#else
    117117        struct timeval now;
    118118        gettimeofday(&now, NULL);
    119         return (uint32)( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) );
     119        return static_cast<uint64>( (now.tv_sec - zero_timer.timeval_zero.tv_sec)*1000000+(now.tv_usec - zero_timer.timeval_zero.tv_usec) );
    120120#endif
    121121}
  • trunk/src/stl/assert.cc

    r396 r402  
    3131extern "C" {
    3232        extern void __assert(const char *, const char *, unsigned int, const char *)
    33                 throw() __attribute__ ((__noreturn__));
     33                __attribute__ ((__noreturn__));
    3434}
    3535#       else
    3636extern "C" {
    3737        extern void __assert_fail(const char *, const char *, unsigned int, const char *)
    38                 throw() __attribute__ ((__noreturn__));
     38                __attribute__ ((__noreturn__));
    3939}
    4040#       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 )
    4242{
    4343#       if NV_COMPILER == NV_CLANG
  • trunk/src/stl/hash_table.cc

    r395 r402  
    4747};
    4848
    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 ) );
    5050
    5151namespace nv
    5252{
    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 ) ) };
    5454}
    5555
  • trunk/src/stl/string.cc

    r395 r402  
    1515using namespace nv;
    1616
    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 };
    1918
    2019std::string nv::slurp( const std::string& filename )
     
    4140{
    4241        char* s = str;
    43         uint32 abs = ( n < 0 ) ? (uint32)( -n ) : (uint32)( n );
     42        uint32 abs = static_cast< uint32 >( n < 0 ? -n : n );
    4443        do
    4544        {
    46                 *s++ = (char)( '0' + ( abs % 10 ) );
     45                *s++ = static_cast<char>( '0' + ( abs % 10 ) );
    4746                abs /= 10;
    4847        } while ( abs > 0 );
     
    5049        *s = '\0';
    5150        string_reverse( str, s - 1 );
    52         return (nv::size_t)( s - str );
     51        return static_cast<nv::size_t>( s - str );
    5352}
    5453
     
    5655{
    5756        char* s = str;
    58         uint64 abs = ( n < 0 ) ? (uint64)( -n ) : (uint64)( n );
     57        uint64 abs = static_cast< uint64 >( n < 0 ? -n : n );
    5958        do
    6059        {
    61                 *s++ = (char)( '0' + ( abs % 10 ) );
     60                *s++ = static_cast<char>( '0' + ( abs % 10 ) );
    6261                abs /= 10;
    6362        } while ( abs > 0 );
     
    6564        *s = '\0';
    6665        string_reverse( str, s - 1 );
    67         return (nv::size_t)( s - str );
     66        return static_cast<nv::size_t>( s - str );
    6867}
    6968
     
    7372        do
    7473        {
    75                 *s++ = (char)( '0' + ( n % 10 ) );
     74                *s++ = static_cast<char>( '0' + ( n % 10 ) );
    7675                n /= 10;
    7776        } while ( n > 0 );
    7877        *s = '\0';
    7978        string_reverse( str, s - 1 );
    80         return (nv::size_t)( s - str );
     79        return static_cast<nv::size_t>( s - str );
    8180}
    8281
     
    8685        do
    8786        {
    88                 *s++ = (char)( '0' + ( n % 10 ) );
     87                *s++ = static_cast<char>( '0' + ( n % 10 ) );
    8988                n /= 10;
    9089        } while ( n > 0 );
    9190        *s = '\0';
    9291        string_reverse( str, s - 1 );
    93         return (size_t)( s - str );
     92        return static_cast<nv::size_t>( s - str );
    9493}
    9594
     
    101100        int result = snprintf( str, 64, "%.*g", 6, n );
    102101#endif
    103         return result > 0 ? ( nv::size_t )result : 0;
     102        return static_cast<nv::size_t>( result > 0 ? result : 0 );
    104103}
    105104
     
    111110        int result = snprintf( str, 64, "%.*g", 6, n );
    112111#endif
    113         return result > 0 ? ( nv::size_t )result : 0;
     112        return static_cast<nv::size_t>( result > 0 ? result : 0 );
    114113}
    115114
    116 sint32 buffer_to_sint32( const char* str, char** end )
     115sint32 nv::buffer_to_sint32( const char* str, char** end )
    117116{
    118117        const char* s = str;
     
    131130                ++s;
    132131        }
    133         if ( end != nullptr ) *end = (char*)s;
     132        if ( end != nullptr ) *end = const_cast<char*>( s );
    134133        return positive ? result : -result;
    135134}
    136135
    137 sint64 buffer_to_sint64( const char* s, char** end )
     136sint64 nv::buffer_to_sint64( const char* s, char** end )
    138137{
    139138        while ( *s == ' ' ) ++s;
     
    151150                ++s;
    152151        }
    153         if ( end != nullptr ) *end = (char*)s;
     152        if ( end != nullptr ) *end = const_cast<char*>( s );
    154153        return positive ? result : -result;
    155154}
    156155
    157 uint32 buffer_to_uint32( const char* s, char** end )
     156uint32 nv::buffer_to_uint32( const char* s, char** end )
    158157{
    159158        while ( *s == ' ' ) ++s;
     
    161160        while ( *s >= '0' && *s <= '9' )
    162161        {
    163                 result = ( result * 10 ) + (uint32)( *s - '0' );
     162                result = ( result * 10 ) + static_cast<uint32>( *s - '0' );
    164163                ++s;
    165164        }
    166         if ( end != nullptr ) *end = (char*)s;
     165        if ( end != nullptr ) *end = const_cast<char*>( s );
    167166        return result;
    168167}
    169168
    170 uint64 buffer_to_uint64( const char* s, char** end )
     169uint64 nv::buffer_to_uint64( const char* s, char** end )
    171170{
    172171        while ( *s == ' ' ) ++s;
     
    174173        while ( *s >= '0' && *s <= '9' )
    175174        {
    176                 result = ( result * 10 ) + (uint32)( *s - '0' );
     175                result = ( result * 10 ) + static_cast<uint32>( *s - '0' );
    177176                ++s;
    178177        }
    179         if ( end != nullptr ) *end = (char*)s;
     178        if ( end != nullptr ) *end = const_cast<char*>( s );
    180179        return result;
    181180}
    182181
    183 float buffer_to_f32( const char* s, char** end )
     182float nv::buffer_to_f32( const char* s, char** end )
    184183{
    185184        return strtof( s, end );
    186185}
    187186
    188 double buffer_to_f64( const char* s, char** end )
     187double nv::buffer_to_f64( const char* s, char** end )
    189188{
    190189        return strtod( s, end );
Note: See TracChangeset for help on using the changeset viewer.