Changeset 382


Ignore:
Timestamp:
06/01/15 20:39:35 (10 years ago)
Author:
epyon
Message:
  • massive C++11 update (upgrade to MSVC 2015)
  • array/dynamic_array - fully based on memory containers (will be moved) (in progress)
Location:
trunk
Files:
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/nv/core/arcball.hh

    r352 r382  
    1515
    1616#include <nv/core/common.hh>
    17 #include <nv/core/math.hh>
     17#include <nv/stl/math.hh>
    1818
    1919namespace nv
  • trunk/nv/core/common.hh

    r379 r382  
    9898#endif
    9999
    100 #if NV_COMPILER == NV_MSVC && NV_COMP_VER < 1700
    101 #error "MSVC 2013+ required!"
     100#if NV_COMPILER == NV_MSVC && NV_COMP_VER < 1900
     101#error "MSVC 2015+ required!"
    102102#endif
    103103
     
    106106#endif
    107107
    108 #if NV_COMPILER == NV_CLANG && NV_COMP_VER < 320
    109 #error "clang 3.2+ required!"
    110 #endif
    111 
    112 // Feature incoming - remove and find when constexpr compiler is used
    113 #define NV_CONSTEXPR
    114 #define NV_CONSTEXPR_CONST const
     108#if NV_COMPILER == NV_CLANG && NV_COMP_VER < 330
     109#error "clang 3.3+ required!"
     110#endif
    115111
    116112#if NV_COMPILER == NV_MSVC
     
    137133#define NV_RESTRICT __declspec(restrict)
    138134#define NV_RESTRICT_VAR __restrict
    139 #define NV_NOEXCEPT throw()
    140 #define NV_ALIGN_OF(type) __alignof(type)
    141135#if NV_ARCHITECTURE == NV_64BIT
    142136#define NV_OFFSET_OF(obj,m) (nv::size_t)( (nv::ptrdiff_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m)) )
    143137#else // NV_32BIT
    144138#define NV_OFFSET_OF(obj,m) (nv::size_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m))
     139#define NV_MSVC_SUPRESS( warn_number ) __pragma( warning( suppress : warn_number ) )
    145140#endif 
    146 //#define NV_CONSTEXPR
    147141#elif NV_COMPILER == NV_GNUC || NV_COMPILER == NV_CLANG
    148142#define NV_DEPRECATED(func) func __attribute__ ((deprecated))
     
    151145#define NV_RESTRICT __restrict__
    152146#define NV_RESTRICT_VAR __restrict__
    153 #define NV_NOEXCEPT noexcept
    154 #define NV_ALIGN_OF(type) alignof(type)
    155147#define NV_OFFSET_OF(obj, m) __builtin_offsetof(obj, m)
    156 //#define NV_CONSTEXPR constexpr
     148#define NV_MSVC_SUPRESS( warn_number )
    157149#else
    158150#error "Unknown compiler, cannot proceed!"
     
    184176        struct static_assert_fail
    185177        {
    186                 static const bool value = false;
     178                static constexpr bool value = false;
    187179        };
    188180
    189         using size_t    = decltype( sizeof(0) );
     181#if NV_COMPILER == NV_MSVC
     182        using ::size_t;
     183#else
     184        using size_t    = decltype( 0 );
     185#endif
    190186        using ptrdiff_t = decltype((int*)0 - (int*)0);
    191 
    192187        using nullptr_t = decltype( nullptr );
     188       
     189#if NV_ARCHITECTURE == NV_64BIT
     190        using uintptr_t = unsigned long long;
     191#else
     192        using uintptr_t = unsigned int;
     193#endif
    193194
    194195        // Typedefs for fixed size types.
     
    225226        struct four_cc
    226227        {
    227                 static const unsigned int value = (((((d << 8) | c) << 8) | b) << 8) | a;
     228                static constexpr unsigned int value = (((((d << 8) | c) << 8) | b) << 8) | a;
    228229        };
    229230
     
    231232        {
    232233        protected:
    233                 NV_CONSTEXPR noncopyable() = default;
     234                constexpr noncopyable() = default;
    234235                ~noncopyable() = default;
    235236                noncopyable( const noncopyable& ) = delete;
     
    244245
    245246        template <typename T, typename U>
    246         T narrow_cast( const U& a )
     247        constexpr T narrow_cast( const U& a )
    247248        {
    248249                return static_cast<T>( a & T( -1 ) );
  • trunk/nv/stl/array.hh

    r376 r382  
    2424namespace nv
    2525{
    26         using std::vector;
     26        using ::std::vector;
    2727
    28         template < typename T, typename Storage >
    29         class array_base
    30                 : public detail::pointer_iterators < array_base< T, Storage >, Storage >
    31         {
    32         public:
    33                 typedef T         value_type;
    34                 typedef size_t    size_type;
    35                 typedef ptrdiff_t difference_type;
    36                 typedef T*        pointer;
    37                 typedef const T*  const_pointer;
    38                 typedef T*        iterator;
    39                 typedef const T*  const_iterator;
    40                 typedef T&        reference;
    41                 typedef const T&  const_reference;
    42                 typedef nv::reverse_iterator<iterator>       reverse_iterator;
    43                 typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
     28        template < typename ContainerAllocator >
     29        using array_base = detail::add_random_access< detail::add_iterators < ContainerAllocator > >;
    4430
    45                 inline const_pointer data() const { return m_storage.data(); }
    46                 inline pointer data() { return m_storage.data(); }
    47                 inline size_t size() const { return m_storage.size(); }
    48                 inline bool empty() const { return m_storage.size() == 0; }
    49                 inline size_type   raw_size() const { return m_storage.size() * sizeof( value_type ); }
    50                 inline const char* raw_data() const { return (const char*)m_storage.data(); }
    51                 inline char*       raw_data() { return (char*)m_storage.data(); }
    52 
    53                 inline reference       front() { NV_ASSERT( !empty(), "front() called on empty data!" );  return m_storage.data()[0]; }
    54                 inline const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_storage.data()[0]; }
    55                 inline reference       back() { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_storage.data()[size() - 1]; }
    56                 inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_storage.data()[size() - 1]; }
    57 
    58                 reference operator[]( size_type i )
    59                 {
    60                         NV_ASSERT( i < m_storage.size(), "Out of range" );
    61                         return m_storage.data()[i];
    62                 }
    63 
    64                 const_reference operator[]( size_type i ) const
    65                 {
    66                         NV_ASSERT( i < m_storage.size(), "Out of range" );
    67                         return m_storage.data()[i];
    68                 }
    69 
    70                 inline void assign( const value_type& value ) { fill( value ); }
    71 
    72                 inline void fill( const value_type& value )
    73                 {
    74                         fill_n( this->begin(), this->size(), value );
    75                 }
    76 
    77                 inline void clear()
    78                 {
    79                         fill_default_n( this->begin(), this->size() );
    80                 }
    81 
    82         protected:
    83                 Storage m_storage;
    84         };
    8531
    8632        template< typename T, size_t N >
    87         using array = array_base < T, fixed_container_storage < static_storage< T, N > > >;
     33        using array = array_base < fixed_container_allocator < fixed_static_storage< T, N > > >;
    8834       
     35        template< typename T >
     36        using dynamic_array = array_base < sized_container_allocator< resizable_dynamic_storage< T > > >;
    8937
    90 #if 0
    91 
    92         template< typename T, size_t N >
    93         class array : public detail::pointer_iterators < array< T, N >, T, false >
    94         {
    95         public:
    96                 typedef T         value_type;
    97                 typedef size_t    size_type;
    98                 typedef ptrdiff_t difference_type;
    99                 typedef T*        pointer;
    100                 typedef const T*  const_pointer;
    101                 typedef T*        iterator;
    102                 typedef const T*  const_iterator;
    103                 typedef T&        reference;
    104                 typedef const T&  const_reference;
    105                 typedef nv::reverse_iterator<iterator>       reverse_iterator;
    106                 typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
    107 
    108                 static const size_type SIZE = N;
    109                 static const size_type ELEMENT_SIZE = sizeof( value_type );
    110 
    111                 inline const_pointer data() const { return m_data; }
    112                 inline pointer data() { return m_data; }
    113                 inline size_type size() const { return SIZE; }
    114                 inline bool empty() const { return false; }
    115                 inline size_type   raw_size() const { return SIZE * sizeof( T ); }
    116                 inline const char* raw_data() const { return (const char*)m_data; }
    117                 inline char*       raw_data() { return (char*)m_data; }
    118 
    119                 inline reference       front() { NV_ASSERT( !empty(), "front() called on empty data!" );  return m_data[0]; }
    120                 inline const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[0]; }
    121                 inline reference       back() { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[SIZE - 1]; }
    122                 inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return m_data[SIZE - 1]; }
    123 
    124                 reference operator[]( size_type i )
    125                 {
    126                         NV_ASSERT( i < N, "Out of range" );
    127                         return this->m_data[i];
    128                 }
    129 
    130                 const_reference operator[]( size_type i ) const
    131                 {     
    132                         NV_ASSERT( i < N, "Out of range" );
    133                         return this->m_data[i];
    134                 }
    135 
    136                 reference at( size_type i )
    137                 {
    138                         NV_ASSERT( i < N, "Out of range" );
    139                         return this->m_data[i];
    140                 }
    141 
    142                 const_reference at( size_type i ) const
    143                 {
    144                         NV_ASSERT( i < N, "Out of range" );
    145                         return this->m_data[i];
    146                 }
    147 
    148                 void assign( const value_type& value ) { fill( value ); }
    149 
    150                 void fill( const value_type& value )
    151                 {
    152                         std::fill_n( this->begin(), this->size(), value );
    153                 }
    154 
    155         private:
    156                 value_type m_data[SIZE];
    157         };
    158 
    159 #endif
    16038//      template < typename T, typename ContainerAllocator >
    16139//      class vector_base
     
    21189//      };
    21290
    213         template< typename T >
    214         class dynamic_array : public detail::data_base< storage_view< T > >
    215         {
    216         public:
    217                 typedef T         value_type;
    218                 typedef T*        iterator;
    219                 typedef const T*  const_iterator;
    220                 typedef T&        reference;
    221                 typedef const T&  const_reference;
    222                 typedef size_t    size_type;
    223                 typedef ptrdiff_t difference_type;
    224 
    225                 typedef nv::reverse_iterator<iterator>       reverse_iterator;
    226                 typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
    227 
    228                 dynamic_array() : detail::data_base< storage_view< T > >() {}
    229 //                      : m_data( nullptr ), m_size(0) {}
    230                 explicit dynamic_array( size_type new_size ) : detail::data_base< storage_view< T > >( new value_type[new_size], new_size ) {}
    231 //                      : m_data( new value_type[ new_size ] ), m_size( new_size ) {}
    232                 dynamic_array( const value_type& value, size_type size ) : detail::data_base< storage_view< T > >()
    233 //                      : m_data( nullptr ), m_size(0)
    234                 { assign( value, size ); }
    235                 dynamic_array( const_iterator values, size_type size ) : detail::data_base< storage_view< T > >()
    236 //                      : m_data( nullptr ), m_size(0)
    237                 { assign( values, size ); }
    238 
    239                 void resize( size_type new_size )
    240                 {
    241                         if ( new_size != this->size() )
    242                         {
    243                                 value_type* old_data = this->data();
    244                                 value_type* new_data = new_size > 0 ? new value_type[new_size] : nullptr;
    245                                 if ( old_data && this->data() )
    246                                 {
    247                                         std::copy_n( old_data, new_size > this->size() ? this->size() : new_size, new_data );
    248                                 }
    249                                 delete[] old_data;
    250                                 assign( new_data, new_size );
    251                         }
    252                 }
    253 
    254 //              iterator        begin()        { return m_data; }
    255 //              const_iterator  begin()  const { return m_data; }
    256 //              const_iterator  cbegin() const { return m_data; }
    257 //
    258 //              iterator        end()        { return m_data+m_size; }
    259 //              const_iterator  end()  const { return m_data+m_size; }
    260 //              const_iterator  cend() const { return m_data+m_size; }
    261 //
    262 //              reverse_iterator rbegin()              { return reverse_iterator( end() ); }
    263 //              const_reverse_iterator rbegin() const  { return const_reverse_iterator( end() ); }
    264 //              const_reverse_iterator crbegin() const { return const_reverse_iterator( end() ); }
    265 //
    266 //              reverse_iterator rend()                { return reverse_iterator( begin() ); }
    267 //              const_reverse_iterator rend() const    { return const_reverse_iterator( begin() ); }
    268 //              const_reverse_iterator crend() const   { return const_reverse_iterator( begin() ); }
    269 
    270                 reference operator[]( size_type i )
    271                 {
    272                         NV_ASSERT( i < this->size(), "Out of range" );
    273                         return this->data()[i];
    274                 }
    275 
    276                 const_reference operator[]( size_type i ) const
    277                 {     
    278                         NV_ASSERT( i < this->size(), "Out of range" );
    279                         return this->data()[i];
    280                 }
    281 
    282 //              reference       front()       { return m_data[0]; }
    283 //              const_reference front() const { return m_data[0]; }
    284 //              reference       back()        { return m_data[m_size-1]; }
    285 //              const_reference back() const  { return m_data[m_size-1]; }
    286 //
    287 //              size_type        size() const     { return m_size; }
    288 //              bool             empty() const    { return m_size == 0; }
    289 //              static size_type max_size()       { return numeric_limits< size_type >::max(); }
    290 //              const value_type* data() const { return m_data; }
    291 //              value_type*       data()       { return m_data; }
    292 //
    293 //              size_type   raw_size() const { return m_size * ELEMENT_SIZE; }
    294 //              const char* raw_data() const { return (const char*)m_data; }
    295 //              char*       raw_data()       { return (char*)m_data; }
    296 
    297                 void assign( const value_type& value ) { std::fill_n( this->begin(), this->size(), value ); }
    298                 void assign( const value_type& value, size_type new_size )
    299                 {
    300                         resize( new_size );
    301                         std::fill_n( this->begin(), this->size(), value );
    302                 }
    303                 void assign( const_iterator values, size_type new_size )
    304                 {
    305                         resize( new_size );
    306                         std::copy_n( values, this->size(), this->data() );
    307                 }
    308 
    309                 ~dynamic_array() { delete[] this->data(); }
    310 
    311                 static const size_type ELEMENT_SIZE = sizeof(T);
    312         };
    313 
    314 
    315 
    31691}
    31792
  • trunk/nv/stl/capi.hh

    r378 r382  
    4242#endif
    4343                // TODO: remove when clang 3.5 will be used (with builtins)
    44 #if NV_COMPILER == NV_CLANG
     44#if NV_COMPILER == NV_CLANG || NV_COMPILER == NV_GNUC
    4545#define NV_CAPI_CALL(name) detail::name
    4646                extern "C" {
     
    5757                        extern int    __cdecl strncmp( const char * , const char * , size_t );
    5858                        extern nv::size_t __cdecl strlen ( const char * );
    59         }
    60 #endif
    61 
    62 #if NV_COMPILER == NV_GNUC
    63 #define NV_CAPI_CALL(name) __builtin_##name
     59                }
    6460#endif
    6561        }
     
    6864        {
    6965                return NV_CAPI_CALL(malloc)( size );
     66        }
     67        inline void* nvrealloc( void* p, size_t size )
     68        {
     69                if ( size > 0 ) return NV_CAPI_CALL( realloc )( p, size );
     70                NV_CAPI_CALL( free )( p );
     71                return nullptr;
    7072        }
    7173        inline void nvfree( void* p )
  • trunk/nv/stl/cstring_store.hh

    r378 r382  
    6161        using cstring_unordered_map = std::unordered_map < const char*, T, detail::cstring_hash, detail::cstring_compare > ;
    6262
    63         struct cstring_deleter : public noncopyable
    64         {
    65         public:
    66                 cstring_deleter() {}
    67 
    68                 char* duplicate( const char* s )
    69                 {
    70                         char* result = detail::cstring_duplicate( s );
    71                         insert( result );
    72                         return result;
    73                 }
    74 
    75                 void insert( char * s )
    76                 {
    77                         m_array.push_back( s );
    78                 }
    79 
    80                 ~cstring_deleter()
    81                 {
    82                         for ( auto s : m_array ) free( s );
    83                 }
    84         private:
    85                 std::vector< char* > m_array;
    86         };
    87 
    8863        class cstring_store : public noncopyable
    8964        {
  • trunk/nv/stl/limits.hh

    r376 r382  
    2020        struct limits
    2121        {
    22                 static const unsigned char uc_min = 0;
    23                 static const unsigned char uc_max = 255;
    24                 static const unsigned char uc_bit = sizeof( unsigned char ) * 8;
    25                 static const signed char sc_min = -128;
    26                 static const signed char sc_max = 127;
    27                 static const signed char sc_bit = sizeof( signed char ) * 8;
    28                 static const char c_min = ( char( 0 ) < char( -1 ) ? 0 : -128 );
    29                 static const char c_max = ( char( 0 ) < char( -1 ) ? 255 : 127 );
    30                 static const char c_bit = sizeof( char ) * 8;
    31                 static const unsigned short us_min = 0;
    32                 static const unsigned short us_max = 65535;
    33                 static const unsigned short us_bit = sizeof( unsigned short ) * 8;
    34                 static const signed short ss_min = -32768;
    35                 static const signed short ss_max = 32767;
    36                 static const signed short ss_bit = sizeof( signed short ) * 8;
    37                 static const unsigned int ui_min = 0;
    38                 static const unsigned int ui_max = 4294967295;
    39                 static const unsigned int ui_bit = sizeof( unsigned int ) * 8;
    40                 static const signed int si_min = -2147483648;
    41                 static const signed int si_max = 2147483647;
    42                 static const signed int si_bit = sizeof( signed int ) * 8;
    43                 static const unsigned long ul_min = 0;
    44                 static const unsigned long ul_max = 4294967295;
    45                 static const unsigned long ul_bit = sizeof( unsigned long ) * 8;
    46                 static const signed long sl_min = -2147483648;
    47                 static const signed long sl_max = 2147483647;
    48                 static const signed long sl_bit = sizeof( signed long ) * 8;
    49                 static const unsigned long long ull_min = 0;
    50                 static const unsigned long long ull_max = 18446744073709551615;
    51                 static const unsigned long long ull_bit = sizeof( unsigned long long ) * 8;
    52                 static const signed long long sll_min = -9223372036854775808;
    53                 static const signed long long sll_max = 9223372036854775807;
    54                 static const signed long long sll_bit = sizeof( signed long long ) * 8;
    55 
    56                 static const int f_dig        = 6;
    57                 static const int f_mant_dig   = 24;
    58                 static const int f_max_exp    = 128;
    59                 static const int f_max_10_exp = 38;
    60                 static const int f_min_exp    = -125;
    61                 static const int f_min_10_exp = -37;
    62 
    63                 static const int d_dig        = 15;
    64                 static const int d_mant_dig   = 53;
    65                 static const int d_max_exp    = 1024;
    66                 static const int d_max_10_exp = 308;
    67                 static const int d_min_exp    = -1021;
    68                 static const int d_min_10_exp = -307;
    69 
    70                 static const int ld_dig        = d_dig;
    71                 static const int ld_mant_dig   = d_mant_dig;
    72                 static const int ld_max_exp    = d_max_exp;
    73                 static const int ld_max_10_exp = d_max_10_exp;
    74                 static const int ld_min_exp    = d_min_exp;
    75                 static const int ld_min_10_exp = d_min_10_exp;
     22                static constexpr unsigned char uc_min = 0;
     23                static constexpr unsigned char uc_max = 255;
     24                static constexpr unsigned char uc_bit = sizeof( unsigned char ) * 8;
     25                static constexpr signed char sc_min = -128;
     26                static constexpr signed char sc_max = 127;
     27                static constexpr signed char sc_bit = sizeof( signed char ) * 8;
     28                static constexpr char c_min = ( char( 0 ) < char( -1 ) ? 0 : -128 );
     29                static constexpr char c_max = ( char( 0 ) < char( -1 ) ? 255 : 127 );
     30                static constexpr char c_bit = sizeof( char ) * 8;
     31                static constexpr unsigned short us_min = 0;
     32                static constexpr unsigned short us_max = 65535;
     33                static constexpr unsigned short us_bit = sizeof( unsigned short ) * 8;
     34                static constexpr signed short ss_min = -32768;
     35                static constexpr signed short ss_max = 32767;
     36                static constexpr signed short ss_bit = sizeof( signed short ) * 8;
     37                static constexpr unsigned int ui_min = 0;
     38                static constexpr unsigned int ui_max = 4294967295;
     39                static constexpr unsigned int ui_bit = sizeof( unsigned int ) * 8;
     40                static constexpr signed int si_min = -2147483648;
     41                static constexpr signed int si_max = 2147483647;
     42                static constexpr signed int si_bit = sizeof( signed int ) * 8;
     43                static constexpr unsigned long ul_min = 0;
     44                static constexpr unsigned long ul_max = 4294967295;
     45                static constexpr unsigned long ul_bit = sizeof( unsigned long ) * 8;
     46                static constexpr signed long sl_min = -2147483648;
     47                static constexpr signed long sl_max = 2147483647;
     48                static constexpr signed long sl_bit = sizeof( signed long ) * 8;
     49                static constexpr unsigned long long ull_min = 0;
     50                static constexpr unsigned long long ull_max = 18446744073709551615;
     51                static constexpr unsigned long long ull_bit = sizeof( unsigned long long ) * 8;
     52                static constexpr signed long long sll_min = -9223372036854775808;
     53                static constexpr signed long long sll_max = 9223372036854775807;
     54                static constexpr signed long long sll_bit = sizeof( signed long long ) * 8;
     55
     56                static constexpr int f_dig        = 6;
     57                static constexpr int f_mant_dig   = 24;
     58                static constexpr int f_max_exp    = 128;
     59                static constexpr int f_max_10_exp = 38;
     60                static constexpr int f_min_exp    = -125;
     61                static constexpr int f_min_10_exp = -37;
     62
     63                static constexpr int d_dig        = 15;
     64                static constexpr int d_mant_dig   = 53;
     65                static constexpr int d_max_exp    = 1024;
     66                static constexpr int d_max_10_exp = 308;
     67                static constexpr int d_min_exp    = -1021;
     68                static constexpr int d_min_10_exp = -307;
     69
     70                static constexpr int ld_dig        = d_dig;
     71                static constexpr int ld_mant_dig   = d_mant_dig;
     72                static constexpr int ld_max_exp    = d_max_exp;
     73                static constexpr int ld_max_10_exp = d_max_10_exp;
     74                static constexpr int ld_min_exp    = d_min_exp;
     75                static constexpr int ld_min_10_exp = d_min_10_exp;
    7676        };
    7777
     
    9696                struct numeric_limits_base
    9797                {
    98                         static const float_denorm_style has_denorm = denorm_absent;
    99                         static const bool has_denorm_loss   = false;
    100                         static const bool has_infinity      = false;
    101                         static const bool has_quiet_NaN     = false;
    102                         static const bool has_signaling_NaN = false;
    103                         static const bool is_bounded        = false;
    104                         static const bool is_exact          = false;
    105                         static const bool is_iec559         = false;
    106                         static const bool is_integer        = false;
    107                         static const bool is_modulo         = false;
    108                         static const bool is_signed         = false;
    109                         static const bool is_specialized    = false;
    110                         static const bool tinyness_before   = false;
    111                         static const bool traps             = false;
    112                         static const float_round_style round_style = round_toward_zero;
    113                         static const int digits         = 0;
    114                         static const int digits10       = 0;
    115                         static const int max_digits10   = 0;
    116                         static const int max_exponent   = 0;
    117                         static const int max_exponent10 = 0;
    118                         static const int min_exponent   = 0;
    119                         static const int min_exponent10 = 0;
    120                         static const int radix          = 0;
     98                        static constexpr float_denorm_style has_denorm = denorm_absent;
     99                        static constexpr bool has_denorm_loss   = false;
     100                        static constexpr bool has_infinity      = false;
     101                        static constexpr bool has_quiet_NaN     = false;
     102                        static constexpr bool has_signaling_NaN = false;
     103                        static constexpr bool is_bounded        = false;
     104                        static constexpr bool is_exact          = false;
     105                        static constexpr bool is_iec559         = false;
     106                        static constexpr bool is_integer        = false;
     107                        static constexpr bool is_modulo         = false;
     108                        static constexpr bool is_signed         = false;
     109                        static constexpr bool is_specialized    = false;
     110                        static constexpr bool tinyness_before   = false;
     111                        static constexpr bool traps             = false;
     112                        static constexpr float_round_style round_style = round_toward_zero;
     113                        static constexpr int digits         = 0;
     114                        static constexpr int digits10       = 0;
     115                        static constexpr int max_digits10   = 0;
     116                        static constexpr int max_exponent   = 0;
     117                        static constexpr int max_exponent10 = 0;
     118                        static constexpr int min_exponent   = 0;
     119                        static constexpr int min_exponent10 = 0;
     120                        static constexpr int radix          = 0;
    121121                };
    122122
    123123                struct numeric_limits_int_base : public numeric_limits_base
    124124                {
    125                         static const bool is_bounded     = true;
    126                         static const bool is_exact       = true;
    127                         static const bool is_integer     = true;
    128                         static const bool is_modulo      = true;
    129                         static const bool is_specialized = true;
    130                         static const int radix = 2;
     125                        static constexpr bool is_bounded     = true;
     126                        static constexpr bool is_exact       = true;
     127                        static constexpr bool is_integer     = true;
     128                        static constexpr bool is_modulo      = true;
     129                        static constexpr bool is_specialized = true;
     130                        static constexpr int radix = 2;
    131131                };
    132132
    133133                struct numeric_limits_float_base : public numeric_limits_base
    134134                {
    135                         static const float_denorm_style has_denorm = denorm_present;
    136                         static const bool has_denorm_loss   = true;
    137                         static const bool has_infinity      = true;
    138                         static const bool has_quiet_NaN     = true;
    139                         static const bool has_signaling_NaN = true;
    140                         static const bool is_bounded        = true;
    141                         static const bool is_iec559         = true;
    142                         static const bool is_signed         = true;
    143                         static const bool is_specialized    = true;
    144                         static const bool tinyness_before   = true;
    145                         static const float_round_style round_style = round_to_nearest;
    146                         static const int radix = 2;
     135                        static constexpr float_denorm_style has_denorm = denorm_present;
     136                        static constexpr bool has_denorm_loss   = true;
     137                        static constexpr bool has_infinity      = true;
     138                        static constexpr bool has_quiet_NaN     = true;
     139                        static constexpr bool has_signaling_NaN = true;
     140                        static constexpr bool is_bounded        = true;
     141                        static constexpr bool is_iec559         = true;
     142                        static constexpr bool is_signed         = true;
     143                        static constexpr bool is_specialized    = true;
     144                        static constexpr bool tinyness_before   = true;
     145                        static constexpr float_round_style round_style = round_to_nearest;
     146                        static constexpr int radix = 2;
    147147                };
    148148
     
    152152        struct numeric_limits : detail::numeric_limits_base
    153153        {
    154                 static NV_CONSTEXPR T min()           NV_NOEXCEPT { return T( 0 ); }
    155                 static NV_CONSTEXPR T max()           NV_NOEXCEPT { return T( 0 ); }
    156                 static NV_CONSTEXPR T lowest()        NV_NOEXCEPT { return T( 0 ); }
    157                 static NV_CONSTEXPR T epsilon()       NV_NOEXCEPT { return T( 0 ); }
    158                 static NV_CONSTEXPR T round_error()   NV_NOEXCEPT { return T( 0 ); }
     154                static constexpr T min()           noexcept { return T( 0 ); }
     155                static constexpr T max()           noexcept { return T( 0 ); }
     156                static constexpr T lowest()        noexcept { return T( 0 ); }
     157                static constexpr T epsilon()       noexcept { return T( 0 ); }
     158                static constexpr T round_error()   noexcept { return T( 0 ); }
    159159        };
    160160
     
    171171        struct numeric_limits < bool > : detail::numeric_limits_int_base
    172172        {
    173                 static NV_CONSTEXPR bool min()           NV_NOEXCEPT { return false; }
    174                 static NV_CONSTEXPR bool max()           NV_NOEXCEPT { return true; }
    175                 static NV_CONSTEXPR bool lowest()        NV_NOEXCEPT { return false; }
    176                 static NV_CONSTEXPR bool epsilon()       NV_NOEXCEPT { return bool( 0 ); }
    177                 static NV_CONSTEXPR bool round_error()   NV_NOEXCEPT { return bool( 0 ); }
    178 
    179                 static const bool is_modulo = false;
    180                 static const bool is_signed = false;
    181                 static const int  digits    = 1;
    182                 static const int  digits10  = 0;
     173                static constexpr bool min()           noexcept { return false; }
     174                static constexpr bool max()           noexcept { return true; }
     175                static constexpr bool lowest()        noexcept { return false; }
     176                static constexpr bool epsilon()       noexcept { return bool( 0 ); }
     177                static constexpr bool round_error()   noexcept { return bool( 0 ); }
     178
     179                static constexpr bool is_modulo = false;
     180                static constexpr bool is_signed = false;
     181                static constexpr int  digits    = 1;
     182                static constexpr int  digits10  = 0;
    183183        };
    184184
     
    186186        struct numeric_limits < char > : detail::numeric_limits_int_base
    187187        {
    188                 static NV_CONSTEXPR char min()           NV_NOEXCEPT { return limits::c_min; }
    189                 static NV_CONSTEXPR char max()           NV_NOEXCEPT { return limits::c_max; }
    190                 static NV_CONSTEXPR char lowest()        NV_NOEXCEPT { return limits::c_min; }
    191                 static NV_CONSTEXPR char epsilon()       NV_NOEXCEPT { return 0; }
    192                 static NV_CONSTEXPR char round_error()   NV_NOEXCEPT { return 0; }
    193 
    194                 static const bool is_signed = (limits::c_min < 0);
    195                 static const int  digits    = limits::c_bit - ( limits::c_min < 0 ? 1 : 0 );
    196                 static const int  digits10  = (limits::c_bit - ( limits::c_min < 0 ? 1 : 0 )) * 301 / 1000;
     188                static constexpr char min()           noexcept { return limits::c_min; }
     189                static constexpr char max()           noexcept { return limits::c_max; }
     190                static constexpr char lowest()        noexcept { return limits::c_min; }
     191                static constexpr char epsilon()       noexcept { return 0; }
     192                static constexpr char round_error()   noexcept { return 0; }
     193
     194                static constexpr bool is_signed = (limits::c_min < 0);
     195                static constexpr int  digits    = limits::c_bit - ( limits::c_min < 0 ? 1 : 0 );
     196                static constexpr int  digits10  = (limits::c_bit - ( limits::c_min < 0 ? 1 : 0 )) * 301 / 1000;
    197197        };
    198198
     
    200200        struct numeric_limits < unsigned char > : detail::numeric_limits_int_base
    201201        {
    202                 static NV_CONSTEXPR unsigned char min()           NV_NOEXCEPT { return limits::uc_min; }
    203                 static NV_CONSTEXPR unsigned char max()           NV_NOEXCEPT { return limits::uc_max; }
    204                 static NV_CONSTEXPR unsigned char lowest()        NV_NOEXCEPT { return limits::uc_min; }
    205                 static NV_CONSTEXPR unsigned char epsilon()       NV_NOEXCEPT { return 0; }
    206                 static NV_CONSTEXPR unsigned char round_error()   NV_NOEXCEPT { return 0; }
    207 
    208                 static const bool is_signed = false;
    209                 static const int  digits    = limits::c_bit;
    210                 static const int  digits10  = limits::c_bit  * 301 / 1000;
     202                static constexpr unsigned char min()           noexcept { return limits::uc_min; }
     203                static constexpr unsigned char max()           noexcept { return limits::uc_max; }
     204                static constexpr unsigned char lowest()        noexcept { return limits::uc_min; }
     205                static constexpr unsigned char epsilon()       noexcept { return 0; }
     206                static constexpr unsigned char round_error()   noexcept { return 0; }
     207
     208                static constexpr bool is_signed = false;
     209                static constexpr int  digits    = limits::c_bit;
     210                static constexpr int  digits10  = limits::c_bit  * 301 / 1000;
    211211        };
    212212
     
    214214        struct numeric_limits < signed char > : detail::numeric_limits_int_base
    215215        {
    216                 static NV_CONSTEXPR signed char min()           NV_NOEXCEPT { return limits::sc_min; }
    217                 static NV_CONSTEXPR signed char max()           NV_NOEXCEPT { return limits::sc_max; }
    218                 static NV_CONSTEXPR signed char lowest()        NV_NOEXCEPT { return limits::sc_min; }
    219                 static NV_CONSTEXPR signed char epsilon()       NV_NOEXCEPT { return 0; }
    220                 static NV_CONSTEXPR signed char round_error()   NV_NOEXCEPT { return 0; }
    221 
    222                 static const bool is_signed = true;
    223                 static const int  digits    = limits::c_bit - 1;
    224                 static const int  digits10  = (limits::c_bit - 1) * 301 / 1000;
     216                static constexpr signed char min()           noexcept { return limits::sc_min; }
     217                static constexpr signed char max()           noexcept { return limits::sc_max; }
     218                static constexpr signed char lowest()        noexcept { return limits::sc_min; }
     219                static constexpr signed char epsilon()       noexcept { return 0; }
     220                static constexpr signed char round_error()   noexcept { return 0; }
     221
     222                static constexpr bool is_signed = true;
     223                static constexpr int  digits    = limits::c_bit - 1;
     224                static constexpr int  digits10  = (limits::c_bit - 1) * 301 / 1000;
    225225        };
    226226
     
    229229        struct numeric_limits < unsigned short > : detail::numeric_limits_int_base
    230230        {
    231                 static NV_CONSTEXPR unsigned short min()           NV_NOEXCEPT { return limits::us_min; }
    232                 static NV_CONSTEXPR unsigned short max()           NV_NOEXCEPT { return limits::us_max; }
    233                 static NV_CONSTEXPR unsigned short lowest()        NV_NOEXCEPT { return limits::us_min; }
    234                 static NV_CONSTEXPR unsigned short epsilon()       NV_NOEXCEPT { return 0; }
    235                 static NV_CONSTEXPR unsigned short round_error()   NV_NOEXCEPT { return 0; }
    236 
    237                 static const bool is_signed = false;
    238                 static const int  digits    = limits::us_bit;
    239                 static const int  digits10  = limits::us_bit * 301 / 1000;
     231                static constexpr unsigned short min()           noexcept { return limits::us_min; }
     232                static constexpr unsigned short max()           noexcept { return limits::us_max; }
     233                static constexpr unsigned short lowest()        noexcept { return limits::us_min; }
     234                static constexpr unsigned short epsilon()       noexcept { return 0; }
     235                static constexpr unsigned short round_error()   noexcept { return 0; }
     236
     237                static constexpr bool is_signed = false;
     238                static constexpr int  digits    = limits::us_bit;
     239                static constexpr int  digits10  = limits::us_bit * 301 / 1000;
    240240        };
    241241
     
    243243        struct numeric_limits < signed short > : detail::numeric_limits_int_base
    244244        {
    245                 static NV_CONSTEXPR signed short min()           NV_NOEXCEPT { return limits::ss_min; }
    246                 static NV_CONSTEXPR signed short max()           NV_NOEXCEPT { return limits::ss_max; }
    247                 static NV_CONSTEXPR signed short lowest()        NV_NOEXCEPT { return limits::ss_min; }
    248                 static NV_CONSTEXPR signed short epsilon()       NV_NOEXCEPT { return 0; }
    249                 static NV_CONSTEXPR signed short round_error()   NV_NOEXCEPT { return 0; }
    250 
    251                 static const bool is_signed = true;
    252                 static const int  digits    = limits::ss_bit - 1;
    253                 static const int  digits10  = ( limits::ss_bit - 1 ) * 301 / 1000;
     245                static constexpr signed short min()           noexcept { return limits::ss_min; }
     246                static constexpr signed short max()           noexcept { return limits::ss_max; }
     247                static constexpr signed short lowest()        noexcept { return limits::ss_min; }
     248                static constexpr signed short epsilon()       noexcept { return 0; }
     249                static constexpr signed short round_error()   noexcept { return 0; }
     250
     251                static constexpr bool is_signed = true;
     252                static constexpr int  digits    = limits::ss_bit - 1;
     253                static constexpr int  digits10  = ( limits::ss_bit - 1 ) * 301 / 1000;
    254254        };
    255255
     
    257257        struct numeric_limits < unsigned int > : detail::numeric_limits_int_base
    258258        {
    259                 static NV_CONSTEXPR unsigned int min()           NV_NOEXCEPT { return limits::ui_min; }
    260                 static NV_CONSTEXPR unsigned int max()           NV_NOEXCEPT { return limits::ui_max; }
    261                 static NV_CONSTEXPR unsigned int lowest()        NV_NOEXCEPT { return limits::ui_min; }
    262                 static NV_CONSTEXPR unsigned int epsilon()       NV_NOEXCEPT { return 0; }
    263                 static NV_CONSTEXPR unsigned int round_error()   NV_NOEXCEPT { return 0; }
    264 
    265                 static const bool is_signed = false;
    266                 static const int  digits    = limits::ui_bit;
    267                 static const int  digits10  = limits::ui_bit * 301 / 1000;
     259                static constexpr unsigned int min()           noexcept { return limits::ui_min; }
     260                static constexpr unsigned int max()           noexcept { return limits::ui_max; }
     261                static constexpr unsigned int lowest()        noexcept { return limits::ui_min; }
     262                static constexpr unsigned int epsilon()       noexcept { return 0; }
     263                static constexpr unsigned int round_error()   noexcept { return 0; }
     264
     265                static constexpr bool is_signed = false;
     266                static constexpr int  digits    = limits::ui_bit;
     267                static constexpr int  digits10  = limits::ui_bit * 301 / 1000;
    268268        };
    269269
     
    271271        struct numeric_limits < signed int > : detail::numeric_limits_int_base
    272272        {
    273                 static NV_CONSTEXPR signed int min()           NV_NOEXCEPT { return limits::si_min; }
    274                 static NV_CONSTEXPR signed int max()           NV_NOEXCEPT { return limits::si_max; }
    275                 static NV_CONSTEXPR signed int lowest()        NV_NOEXCEPT { return limits::si_min; }
    276                 static NV_CONSTEXPR signed int epsilon()       NV_NOEXCEPT { return 0; }
    277                 static NV_CONSTEXPR signed int round_error()   NV_NOEXCEPT { return 0; }
    278 
    279                 static const bool is_signed = true;
    280                 static const int  digits    = limits::si_bit - 1;
    281                 static const int  digits10  = ( limits::si_bit - 1 ) * 301 / 1000;
     273                static constexpr signed int min()           noexcept { return limits::si_min; }
     274                static constexpr signed int max()           noexcept { return limits::si_max; }
     275                static constexpr signed int lowest()        noexcept { return limits::si_min; }
     276                static constexpr signed int epsilon()       noexcept { return 0; }
     277                static constexpr signed int round_error()   noexcept { return 0; }
     278
     279                static constexpr bool is_signed = true;
     280                static constexpr int  digits    = limits::si_bit - 1;
     281                static constexpr int  digits10  = ( limits::si_bit - 1 ) * 301 / 1000;
    282282        };
    283283
     
    285285        struct numeric_limits < unsigned long > : detail::numeric_limits_int_base
    286286        {
    287                 static NV_CONSTEXPR unsigned long min()           NV_NOEXCEPT { return limits::ul_min; }
    288                 static NV_CONSTEXPR unsigned long max()           NV_NOEXCEPT { return limits::ul_max; }
    289                 static NV_CONSTEXPR unsigned long lowest()        NV_NOEXCEPT { return limits::ul_min; }
    290                 static NV_CONSTEXPR unsigned long epsilon()       NV_NOEXCEPT { return 0; }
    291                 static NV_CONSTEXPR unsigned long round_error()   NV_NOEXCEPT { return 0; }
    292 
    293                 static const bool is_signed = false;
    294                 static const int  digits    = limits::ul_bit;
    295                 static const int  digits10  = limits::ul_bit * 301 / 1000;
     287                static constexpr unsigned long min()           noexcept { return limits::ul_min; }
     288                static constexpr unsigned long max()           noexcept { return limits::ul_max; }
     289                static constexpr unsigned long lowest()        noexcept { return limits::ul_min; }
     290                static constexpr unsigned long epsilon()       noexcept { return 0; }
     291                static constexpr unsigned long round_error()   noexcept { return 0; }
     292
     293                static constexpr bool is_signed = false;
     294                static constexpr int  digits    = limits::ul_bit;
     295                static constexpr int  digits10  = limits::ul_bit * 301 / 1000;
    296296        };
    297297
     
    299299        struct numeric_limits < signed long > : detail::numeric_limits_int_base
    300300        {
    301                 static NV_CONSTEXPR signed long min()           NV_NOEXCEPT { return limits::sl_min; }
    302                 static NV_CONSTEXPR signed long max()           NV_NOEXCEPT { return limits::sl_max; }
    303                 static NV_CONSTEXPR signed long lowest()        NV_NOEXCEPT { return limits::sl_min; }
    304                 static NV_CONSTEXPR signed long epsilon()       NV_NOEXCEPT { return 0; }
    305                 static NV_CONSTEXPR signed long round_error()   NV_NOEXCEPT { return 0; }
    306 
    307                 static const bool is_signed = true;
    308                 static const int  digits    = limits::sl_bit - 1;
    309                 static const int  digits10  = ( limits::sl_bit - 1 ) * 301 / 1000;
     301                static constexpr signed long min()           noexcept { return limits::sl_min; }
     302                static constexpr signed long max()           noexcept { return limits::sl_max; }
     303                static constexpr signed long lowest()        noexcept { return limits::sl_min; }
     304                static constexpr signed long epsilon()       noexcept { return 0; }
     305                static constexpr signed long round_error()   noexcept { return 0; }
     306
     307                static constexpr bool is_signed = true;
     308                static constexpr int  digits    = limits::sl_bit - 1;
     309                static constexpr int  digits10  = ( limits::sl_bit - 1 ) * 301 / 1000;
    310310        };
    311311
     
    313313        struct numeric_limits < unsigned long long > : detail::numeric_limits_int_base
    314314        {
    315                 static NV_CONSTEXPR unsigned long long min()           NV_NOEXCEPT { return limits::ull_min; }
    316                 static NV_CONSTEXPR unsigned long long max()           NV_NOEXCEPT{ return limits::ull_max; }
    317                 static NV_CONSTEXPR unsigned long long lowest()        NV_NOEXCEPT{ return limits::ull_min; }
    318                 static NV_CONSTEXPR unsigned long long epsilon()       NV_NOEXCEPT{ return 0; }
    319                 static NV_CONSTEXPR unsigned long long round_error()   NV_NOEXCEPT{ return 0; }
    320 
    321                 static const bool is_signed = false;
    322                 static const int  digits    = limits::ull_bit;
    323                 static const int  digits10  = limits::ull_bit * 301 / 1000;
     315                static constexpr unsigned long long min()           noexcept { return limits::ull_min; }
     316                static constexpr unsigned long long max()           noexcept { return limits::ull_max; }
     317                static constexpr unsigned long long lowest()        noexcept { return limits::ull_min; }
     318                static constexpr unsigned long long epsilon()       noexcept { return 0; }
     319                static constexpr unsigned long long round_error()   noexcept { return 0; }
     320
     321                static constexpr bool is_signed = false;
     322                static constexpr int  digits    = limits::ull_bit;
     323                static constexpr int  digits10  = limits::ull_bit * 301 / 1000;
    324324        };
    325325
     
    327327        struct numeric_limits < signed long long > : detail::numeric_limits_int_base
    328328        {
    329                 static NV_CONSTEXPR signed long long min()           NV_NOEXCEPT{ return limits::sll_min; }
    330                 static NV_CONSTEXPR signed long long max()           NV_NOEXCEPT{ return limits::sll_max; }
    331                 static NV_CONSTEXPR signed long long lowest()        NV_NOEXCEPT{ return limits::sll_min; }
    332                 static NV_CONSTEXPR signed long long epsilon()       NV_NOEXCEPT{ return 0; }
    333                 static NV_CONSTEXPR signed long long round_error()   NV_NOEXCEPT{ return 0; }
    334 
    335                 static const bool is_signed = true;
    336                 static const int  digits    = limits::sll_bit - 1;
    337                 static const int  digits10  = ( limits::sll_bit - 1 ) * 301 / 1000;
     329                static constexpr signed long long min()           noexcept { return limits::sll_min; }
     330                static constexpr signed long long max()           noexcept { return limits::sll_max; }
     331                static constexpr signed long long lowest()        noexcept { return limits::sll_min; }
     332                static constexpr signed long long epsilon()       noexcept { return 0; }
     333                static constexpr signed long long round_error()   noexcept { return 0; }
     334
     335                static constexpr bool is_signed = true;
     336                static constexpr int  digits    = limits::sll_bit - 1;
     337                static constexpr int  digits10  = ( limits::sll_bit - 1 ) * 301 / 1000;
    338338        };
    339339
     
    341341        struct numeric_limits < float > : detail::numeric_limits_float_base
    342342        {
    343                 static NV_CONSTEXPR float min()           NV_NOEXCEPT { return 1.175494351e-38F; }
    344                 static NV_CONSTEXPR float max()           NV_NOEXCEPT { return 3.402823466e+38F; }
    345                 static NV_CONSTEXPR float lowest()        NV_NOEXCEPT { return -max(); }
    346                 static NV_CONSTEXPR float epsilon()       NV_NOEXCEPT { return 1.192092896e-07F; }
    347                 static NV_CONSTEXPR float round_error()   NV_NOEXCEPT { return 0.5F; }
    348 
    349                 static const int digits         = limits::f_mant_dig;
    350                 static const int digits10       = limits::f_dig;
    351                 static const int max_digits10   = 2 + limits::f_dig * 301 / 1000;
    352                 static const int max_exponent   = limits::f_max_exp;
    353                 static const int max_exponent10 = limits::f_max_10_exp;
    354                 static const int min_exponent   = limits::f_min_exp;
    355                 static const int min_exponent10 = limits::f_min_10_exp;
     343                static constexpr float min()           noexcept { return 1.175494351e-38F; }
     344                static constexpr float max()           noexcept { return 3.402823466e+38F; }
     345                static constexpr float lowest()        noexcept { return -max(); }
     346                static constexpr float epsilon()       noexcept { return 1.192092896e-07F; }
     347                static constexpr float round_error()   noexcept { return 0.5F; }
     348
     349                static constexpr int digits         = limits::f_mant_dig;
     350                static constexpr int digits10       = limits::f_dig;
     351                static constexpr int max_digits10   = 2 + limits::f_dig * 301 / 1000;
     352                static constexpr int max_exponent   = limits::f_max_exp;
     353                static constexpr int max_exponent10 = limits::f_max_10_exp;
     354                static constexpr int min_exponent   = limits::f_min_exp;
     355                static constexpr int min_exponent10 = limits::f_min_10_exp;
    356356        };
    357357
     
    359359        struct numeric_limits < double > : detail::numeric_limits_float_base
    360360        {
    361                 static NV_CONSTEXPR double min()           NV_NOEXCEPT { return 2.2250738585072014e-308; }
    362                 static NV_CONSTEXPR double max()           NV_NOEXCEPT { return 1.7976931348623158e+308; }
    363                 static NV_CONSTEXPR double lowest()        NV_NOEXCEPT { return -max(); }
    364                 static NV_CONSTEXPR double epsilon()       NV_NOEXCEPT { return 2.2204460492503131e-016; }
    365                 static NV_CONSTEXPR double round_error()   NV_NOEXCEPT { return 0.5; }
    366 
    367                 static const int digits         = limits::d_mant_dig;
    368                 static const int digits10       = limits::d_dig;
    369                 static const int max_digits10   = 2 + limits::d_dig * 301 / 1000;
    370                 static const int max_exponent   = limits::d_max_exp;
    371                 static const int max_exponent10 = limits::d_max_10_exp;
    372                 static const int min_exponent   = limits::d_min_exp;
    373                 static const int min_exponent10 = limits::d_min_10_exp;
     361                static constexpr double min()           noexcept { return 2.2250738585072014e-308; }
     362                static constexpr double max()           noexcept { return 1.7976931348623158e+308; }
     363                static constexpr double lowest()        noexcept { return -max(); }
     364                static constexpr double epsilon()       noexcept { return 2.2204460492503131e-016; }
     365                static constexpr double round_error()   noexcept { return 0.5; }
     366
     367                static constexpr int digits         = limits::d_mant_dig;
     368                static constexpr int digits10       = limits::d_dig;
     369                static constexpr int max_digits10   = 2 + limits::d_dig * 301 / 1000;
     370                static constexpr int max_exponent   = limits::d_max_exp;
     371                static constexpr int max_exponent10 = limits::d_max_10_exp;
     372                static constexpr int min_exponent   = limits::d_min_exp;
     373                static constexpr int min_exponent10 = limits::d_min_10_exp;
    374374        };
    375375
     
    377377        struct numeric_limits < long double > : detail::numeric_limits_float_base
    378378        {
    379                 static NV_CONSTEXPR long double min()           NV_NOEXCEPT { return 2.2250738585072014e-308; }
    380                 static NV_CONSTEXPR long double max()           NV_NOEXCEPT { return 1.7976931348623158e+308; }
    381                 static NV_CONSTEXPR long double lowest()        NV_NOEXCEPT { return -max(); }
    382                 static NV_CONSTEXPR long double epsilon()       NV_NOEXCEPT { return 2.2204460492503131e-016; }
    383                 static NV_CONSTEXPR long double round_error()   NV_NOEXCEPT { return 0.5; }
    384 
    385                 static const int digits         = limits::ld_mant_dig;
    386                 static const int digits10       = limits::ld_dig;
    387                 static const int max_digits10   = 2 + limits::ld_dig * 301 / 1000;
    388                 static const int max_exponent   = limits::ld_max_exp;
    389                 static const int max_exponent10 = limits::ld_max_10_exp;
    390                 static const int min_exponent   = limits::ld_min_exp;
    391                 static const int min_exponent10 = limits::ld_min_10_exp;
     379                static constexpr long double min()           noexcept { return 2.2250738585072014e-308; }
     380                static constexpr long double max()           noexcept { return 1.7976931348623158e+308; }
     381                static constexpr long double lowest()        noexcept { return -max(); }
     382                static constexpr long double epsilon()       noexcept { return 2.2204460492503131e-016; }
     383                static constexpr long double round_error()   noexcept { return 0.5; }
     384
     385                static constexpr int digits         = limits::ld_mant_dig;
     386                static constexpr int digits10       = limits::ld_dig;
     387                static constexpr int max_digits10   = 2 + limits::ld_dig * 301 / 1000;
     388                static constexpr int max_exponent   = limits::ld_max_exp;
     389                static constexpr int max_exponent10 = limits::ld_max_10_exp;
     390                static constexpr int min_exponent   = limits::ld_min_exp;
     391                static constexpr int min_exponent10 = limits::ld_min_10_exp;
    392392        };
    393393
  • trunk/nv/stl/memory.hh

    r377 r382  
    2525namespace nv
    2626{
     27        namespace detail
     28        {
     29                template< typename T >
     30                struct addressof_helper
     31                {
     32                        T & value;
     33                        constexpr addressof_helper( T & v ) : value( v ) {}
     34                        constexpr operator T& () const { return value; }
     35                private:
     36                        addressof_helper & operator=( const addressof_helper & );
     37                };
     38
     39                template< typename T >
     40                struct addressof_impl
     41                {
     42                        static constexpr T * f( T & v, long )
     43                        {
     44                                return reinterpret_cast<T*>(
     45                                        &const_cast<char&>( reinterpret_cast<const volatile char &>( v ) ) );
     46                        }
     47                        static constexpr T * f( T * v, int ) { return v; }
     48                };
     49        }
     50
     51        template< typename T >
     52        T * addressof( T & v )
     53        {
     54                return detail::addressof_impl<T>::f( detail::addressof_helper<T>( v ), 0 );
     55        }
     56
     57        namespace mem_flags
     58        {
     59                static constexpr uint16 is_const  = 0x0001;
     60                static constexpr uint16 is_static = 0x0002;
     61                static constexpr uint16 read_only = 0x0004;
     62                static constexpr uint16 temporary = 0x0008;
     63        }
    2764
    2865        template< typename T >
     
    3269                typedef T      value_type;
    3370                typedef size_t size_type;
    34                 static const bool is_static = false;
    35                 static const bool is_fixed  = false;
    36                 static const bool is_const  = false;
    37 
    38                 NV_CONSTEXPR storage_view()
     71                static constexpr bool is_static   = false;
     72                static constexpr bool is_fixed    = false;
     73                static constexpr bool is_const    = false;
     74                static constexpr size_t type_size = sizeof( value_type );
     75
     76                constexpr storage_view()
    3977                        : m_data( nullptr ), m_size( 0 ) {}
    40                 NV_CONSTEXPR storage_view( value_type* a_data, size_type a_size )
     78                constexpr storage_view( value_type* a_data, size_type a_size )
    4179                        : m_data( a_data ), m_size( a_size ) {}
    4280
     
    4785                }
    4886
    49                 NV_CONSTEXPR size_t size() const { return m_size; }
    50                 NV_CONSTEXPR value_type* data() { return m_data; }
    51                 NV_CONSTEXPR const value_type* data() const { return m_data; }
     87                constexpr size_t size() const { return m_size; }
     88                constexpr bool empty() const { return m_size != 0; }
     89                constexpr const value_type* data() const { return m_data; }
     90                inline    value_type* data() { return m_data; }
     91                constexpr size_type   raw_size() const { return sizeof( value_type ) * m_size; }
     92                constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
     93                inline    char* raw_data() { return reinterpret_cast<char*>( m_data ); }
    5294        protected:
    5395                value_type* m_data;
     
    59101        {
    60102        public:
    61                 typedef T      value_type;
    62                 typedef size_t size_type;
    63                 static const bool is_static = false;
    64                 static const bool is_fixed  = false;
    65                 static const bool is_const  = true;
    66 
    67                 NV_CONSTEXPR const_storage_view()
     103                typedef T        value_type;
     104                typedef size_t   size_type;
     105                static constexpr bool is_static   = false;
     106                static constexpr bool is_fixed    = false;
     107                static constexpr bool is_const    = true;
     108                static constexpr size_t type_size = sizeof( value_type );
     109
     110                constexpr const_storage_view()
    68111                        : m_data( nullptr ), m_size( 0 ) {}
    69                 NV_CONSTEXPR const_storage_view( const value_type* a_data, size_type a_size )
     112                constexpr const_storage_view( const value_type* a_data, size_type a_size )
    70113                        : m_data( a_data ), m_size( a_size ) {}
    71114
     
    76119                }
    77120
    78                 NV_CONSTEXPR size_t size() const { return m_size; }
    79                 NV_CONSTEXPR const value_type* data() const { return m_data; }
     121                constexpr size_type size() const { return m_size; }
     122                constexpr bool empty() const { return m_size != 0; }
     123                constexpr const value_type* data() const { return m_data; }
     124                constexpr size_type   raw_size() const { return sizeof( value_type ) * m_size; }
     125                constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
    80126        protected:
    81127                const value_type* m_data;
     
    84130
    85131
    86         template< typename T, size_t N >
    87         class static_storage
    88         {
    89         public:
    90                 typedef T value_type;
    91                 static const bool is_static = true;
    92                 static const bool is_fixed  = true;
    93                 static const bool is_const  = false;
    94 
    95                 NV_CONSTEXPR T* data() { return static_cast<T*>( m_data ); }
    96                 NV_CONSTEXPR const T* data() const { return static_cast<const T*>( m_data ); }
    97                 static NV_CONSTEXPR size_t capacity() { return N; }
    98         protected:
    99                 typedef aligned_array_t<T, N, NV_ALIGN_OF( T ) > storage_type;
    100                 storage_type m_data;
    101         };
    102 
    103         template< typename T, size_t N >
    104         class fixed_dynamic_storage
    105         {
    106         public:
    107                 typedef T value_type;
    108                 static const bool is_static = false;
    109                 static const bool is_fixed = true;
    110                 static const bool is_const = false;
    111 
    112                 fixed_dynamic_storage()
    113                 {
    114                         m_data = nvmalloc( N * sizeof( value_type ) );
    115                 }
    116                 ~fixed_dynamic_storage()
    117                 {
    118                         nvfree( m_data );
    119                 }
    120                 static NV_CONSTEXPR size_t capacity() { return N; }
    121                 NV_CONSTEXPR T* data() { return static_cast<T*>( m_data ); }
    122                 NV_CONSTEXPR const T* data() const { return static_cast<const T*>( m_data ); }
    123         protected:
    124                 uint8* m_data;
    125         };
    126 
     132        template < typename T >
     133        inline void raw_construct_object( void* object )
     134        {
     135                new ( object )T;
     136        }
     137
     138        template < typename T, typename ...Args >
     139        inline void raw_construct_object( void* object, Args&&... params )
     140        {
     141                new ( object )T( forward<Args>( params )... );
     142        }
     143
     144        template < typename T, typename ...Args >
     145        inline void construct_object( T* object, Args&&... params )
     146        {
     147                new ( object )T( forward<Args>( params )... );
     148        }
     149
     150        template < typename T >
     151        inline void destroy_object( T* object )
     152        {
     153                object->~T();
     154        }
     155
     156        template <typename TYPE>
     157        void raw_destroy_object( void* object )
     158        {
     159                ( (TYPE*)object )->TYPE::~TYPE();
     160        }
    127161
    128162        namespace detail
     
    220254                }
    221255
     256                template < typename InputIterator, typename ForwardIterator >
     257                inline ForwardIterator uninitialized_copy_impl( InputIterator first, InputIterator last, ForwardIterator out, false_type )
     258                {
     259                        typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
     260                        InputIterator src( first );
     261                        ForwardIterator dest( out );
     262                        for ( ; first != last; ++src, ++dest )
     263                        {
     264                                ::new ( static_cast<void*>( addressof( *dest ) ) ) value_type( *src );
     265                        }
     266                        return dest;
     267                }
     268
     269                template < typename InputIterator, typename ForwardIterator >
     270                inline ForwardIterator uninitialized_copy_impl( InputIterator first, InputIterator last, ForwardIterator out, true_type )
     271                {
     272                        return ForwardIterator( nvmemmove( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first ) ) );
     273                }
     274
     275                template < typename InputIterator, typename ForwardIterator >
     276                inline ForwardIterator uninitialized_copy_n_impl( InputIterator first, size_t count, ForwardIterator out, false_type )
     277                {
     278                        typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
     279                        InputIterator src( first );
     280                        ForwardIterator dest( out );
     281                        for ( ; count > 0; --count, ++src, ++dest )
     282                        {
     283                                ::new ( static_cast<void*>( addressof( *dest ) ) ) value_type( *src );
     284                        }
     285                        return it;
     286                }
     287
     288                template < typename InputIterator, typename ForwardIterator >
     289                inline ForwardIterator uninitialized_copy_n_impl( InputIterator first, size_t count, ForwardIterator out, true_type )
     290                {
     291                        typedef typename std::iterator_traits<ForwardIterator>::value_type value_type;
     292                        return ForwardIterator( nvmemmove( out, first, count * sizeof( value_type ) ) );
     293                }
     294
    222295        }
    223296
     
    235308                return detail::uninitialized_fill_n_impl( first, count, value, has_trivial_assign<value_type>() );
    236309        }
    237 
    238         template < typename T >
    239         inline void raw_construct_object( void* object )
    240         {
    241                 new (object)T;
    242         }
    243 
    244         template < typename T, typename ...Args >
    245         inline void raw_construct_object( void* object, Args&&... params )
    246         {
    247                 new (object)T( forward<Args>( params )... );
    248         }
    249 
    250         template < typename T, typename ...Args >
    251         inline void construct_object( T* object, Args&&... params )
    252         {
    253                 new (object)T( forward<Args>( params )... );
    254         }
    255 
    256         template < typename T >
    257         inline void destroy_object( T* object )
    258         {
    259                 object->~T();
    260         }
    261 
    262         template <typename TYPE>
    263         void raw_destroy_object( void* object )
    264         {
    265                 ( (TYPE*)object )->TYPE::~TYPE();
    266         }
    267 
    268310
    269311        template < typename ForwardIterator, typename ...Args >
     
    304346        }
    305347
     348        template < typename InputIterator, typename ForwardIterator >
     349        inline ForwardIterator uninitialized_copy( InputIterator first, InputIterator last, ForwardIterator out )
     350        {
     351                typedef typename iterator_traits< ForwardIterator >::value_type value_type;
     352                return detail::uninitialized_copy_impl( first, last, out, has_trivial_copy<value_type>() );
     353        }
     354
     355        template < typename InputIterator, typename ForwardIterator >
     356        inline ForwardIterator uninitialized_copy_n( InputIterator first, size_t count, ForwardIterator out )
     357        {
     358                typedef typename iterator_traits< ForwardIterator >::value_type value_type;
     359                return detail::uninitialized_copy_n_impl( first, count, out, has_trivial_copy<value_type>() );
     360        }
     361
    306362        namespace detail
    307363        {
    308                 template < typename PARENT, typename Storage, bool Const = Storage::is_const >
    309                 class pointer_iterators {};
    310 
    311                 template < typename PARENT, typename Storage >
    312                 class pointer_iterators< PARENT, Storage, true >
     364
     365                template < typename Super, bool Const = Super::is_const >
     366                class add_iterators {};
     367
     368                template < typename Super >
     369                class add_iterators < Super, true > : public Super
    313370                {
    314371                public:
    315                         typedef typename Storage::value_type         value_type;
     372                        typedef typename Super::value_type           value_type;
    316373                        typedef const value_type*                    const_iterator;
    317374                        typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
    318375
    319                         inline const_iterator begin() const { return const_iterator( static_cast<const PARENT&>( *this ).data() ); }
    320                         inline const_iterator end() const { return const_iterator( static_cast<const PARENT&>( *this ).data() + static_cast<const PARENT&>( *this ).size() ); }
    321                         inline const_iterator cbegin() const { return const_iterator( static_cast<const PARENT&>( *this ).data() ); }
    322                         inline const_iterator cend() const { return const_iterator( static_cast<const PARENT&>( *this ).data() + static_cast<const PARENT&>( *this ).size() ); }
     376                        using Super::Super;
     377
     378                        inline const_iterator begin() const { return const_iterator( Super::data() ); }
     379                        inline const_iterator end() const { return const_iterator( Super::data() + Super::size() ); }
     380                        inline const_iterator cbegin() const { return const_iterator( Super::data() ); }
     381                        inline const_iterator cend() const { return const_iterator( Super::data() + Super::size() ); }
    323382                        inline const_reverse_iterator rbegin() const { return const_reverse_iterator( end() ); }
    324383                        inline const_reverse_iterator crbegin() const { return const_reverse_iterator( end() ); }
    325384                        inline const_reverse_iterator rend() const { return const_reverse_iterator( begin() ); }
    326385                        inline const_reverse_iterator crend() const { return const_reverse_iterator( begin() ); }
    327                         inline const_iterator iat( size_t i ) const { NV_ASSERT( i <= static_cast<const PARENT&>( *this ).size(), "Index out of range" ); return begin() + i; }
     386                        inline const_iterator iat( size_t i ) const { NV_ASSERT( i <= Super::size(), "Index out of range" ); return begin() + i; }
    328387                };
    329388
    330                 template < typename PARENT, typename Storage >
    331                 class pointer_iterators< PARENT, Storage, false >
     389                template < typename Super >
     390                class add_iterators < Super, false > : public Super
    332391                {
    333392                public:
    334                         typedef typename Storage::value_type         value_type;
     393                        typedef typename Super::value_type           value_type;
    335394                        typedef value_type*                          iterator;
    336395                        typedef const value_type*                    const_iterator;
     
    338397                        typedef nv::reverse_iterator<const_iterator> const_reverse_iterator;
    339398
    340                         inline const_iterator begin() const { return const_iterator( static_cast<const PARENT&>( *this ).data() ); }
    341                         inline const_iterator end() const { return const_iterator( static_cast<const PARENT&>( *this ).data() + static_cast<const PARENT&>( *this ).size() ); }
    342                         inline iterator begin() { return iterator( static_cast<PARENT&>( *this ).data() ); }
    343                         inline iterator end() { return iterator( static_cast<PARENT&>( *this ).data() + static_cast<const PARENT&>( *this ).size() ); }
    344                         inline const_iterator cbegin() const { return const_iterator( static_cast<const PARENT&>( *this ).data() ); }
    345                         inline const_iterator cend() const { return const_iterator( static_cast<const PARENT&>( *this ).data() + static_cast<const PARENT&>( *this ).size() ); }
     399                        using Super::Super;
     400
     401                        inline const_iterator begin() const { return const_iterator( Super::data() ); }
     402                        inline const_iterator end() const { return const_iterator( Super::data() + Super::size() ); }
     403                        inline iterator begin() { return iterator( Super::data() ); }
     404                        inline iterator end() { return iterator( Super::data() + Super::size() ); }
     405                        inline const_iterator cbegin() const { return const_iterator( Super::data() ); }
     406                        inline const_iterator cend() const { return const_iterator( Super::data() + Super::size() ); }
    346407                        inline reverse_iterator rbegin() { return reverse_iterator( end() ); }
    347408                        inline const_reverse_iterator rbegin() const { return const_reverse_iterator( end() ); }
     
    350411                        inline const_reverse_iterator rend() const { return const_reverse_iterator( begin() ); }
    351412                        inline const_reverse_iterator crend() const { return const_reverse_iterator( begin() ); }
    352                         inline const_iterator iat( size_t i ) const { NV_ASSERT( i <= static_cast<const PARENT&>( *this ).size(), "Index out of range" ); return begin() + i; }
    353                         inline iterator       iat( size_t i ) { NV_ASSERT( i <= static_cast<const PARENT&>( *this ).size(), "Index out of range" ); return begin() + i; }
     413                        inline const_iterator iat( size_t i ) const { NV_ASSERT( i <= Super::size(), "Index out of range" ); return begin() + i; }
     414                        inline iterator       iat( size_t i ) { NV_ASSERT( i <= Super::size(), "Index out of range" ); return begin() + i; }
    354415                };
    355416
    356                 template < typename Storage, bool Const = Storage::is_const >
    357                 class data_base;
    358 
    359 
    360                 template < typename Storage >
    361                 class data_base < Storage, true >
    362                         : public pointer_iterators < data_base < Storage, true >, Storage >
     417                template < typename Super, bool Const = Super::is_const >
     418                class add_random_access {};
     419
     420                template < typename Super >
     421                class add_random_access < Super, true > : public Super
    363422                {
    364423                public:
    365                         typedef typename Storage::value_type value_type;
    366                         typedef const value_type*            const_pointer;
    367                         typedef size_t                       size_type;
    368                         typedef const_pointer                const_iterator;
    369                         typedef const value_type&            const_reference;
    370 
    371                         inline data_base() {}
    372                         inline data_base( const_pointer a_data, size_t a_size )
    373                                 : m_view( a_data, a_size ) {}
    374                         inline const_pointer data() const { return m_view.data(); }
    375                         inline size_t size() const { return m_view.size(); }
    376                         inline bool empty() const { return size() != 0; }
    377                         inline size_type   raw_size() const { return sizeof( value_type ) * size(); }
    378                         inline const char* raw_data() const { return (const char*)data(); }
    379 
    380                         inline const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return data()[0]; }
    381                         inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return data()[size() - 1]; }
    382                 protected:
    383                         void assign( const_pointer a_data, size_type a_size )
    384                         {
    385                                 m_view.assign( a_data, a_size );
    386                         }
    387 
    388                         Storage m_view;
     424                        typedef typename Super::value_type           value_type;
     425                        typedef typename Super::size_type            size_type;
     426                        typedef const value_type*                    const_iterator;
     427                        typedef value_type&                          reference;
     428                        typedef const value_type&                    const_reference;
     429
     430                        inline const_reference front() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[0]; }
     431                        inline const_reference back() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[Super::size() - 1]; }
     432
     433                        const_reference operator[]( size_type i ) const
     434                        {
     435                                NV_ASSERT( i < Super::size(), "Out of range" );
     436                                return Super::data()[i];
     437                        }
    389438                };
    390439
    391                 template < typename Storage >
    392                 class data_base < Storage, false >
    393                         : public pointer_iterators < data_base < Storage, false >, Storage >
     440                template < typename Super >
     441                class add_random_access < Super, false > : public Super
    394442                {
    395443                public:
    396                         typedef typename Storage::value_type value_type;
    397                         typedef value_type*                  pointer;
    398                         typedef const value_type*            const_pointer;
    399                         typedef size_t                       size_type;
    400                         typedef pointer                      iterator;
    401                         typedef const_pointer                const_iterator;
    402                         typedef value_type&                          reference;
    403                         typedef const value_type&            const_reference;
    404 
    405                         inline data_base() {}
    406                         inline data_base( pointer a_data, size_t a_size ) : m_view( a_data, a_size ) {}
    407                         inline const_pointer data() const { return m_view.data(); }
    408                         inline pointer data() { return m_view.data(); }
    409                         inline size_t size() const { return m_view.size(); }
    410                         inline bool empty() const { return size() != 0; }
    411                         inline size_type   raw_size() const { return sizeof( value_type ) * size(); }
    412                         inline const char* raw_data() const { return (const char*)data(); }
    413                         inline char*       raw_data() { return (char*)data(); }
    414 
    415                         inline reference       front() { NV_ASSERT( !empty(), "front() called on empty data!" );  return data()[0]; }
    416                         inline const_reference front() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return data()[0]; }
    417                         inline reference       back() { NV_ASSERT( !empty(), "front() called on empty data!" ); return data()[size() - 1]; }
    418                         inline const_reference back() const { NV_ASSERT( !empty(), "front() called on empty data!" ); return data()[size() - 1]; }
    419                 protected:
    420                         void assign( pointer a_data, size_type a_size )
    421                         {
    422                                 m_view.assign( a_data, a_size );
    423                         }
    424 
    425                         Storage m_view;
     444                        typedef typename Super::value_type           value_type;
     445                        typedef typename Super::size_type            size_type;
     446                        typedef value_type*                          iterator;
     447                        typedef const value_type*                    const_iterator;
     448                        typedef value_type&                          reference;
     449                        typedef const value_type&                    const_reference;
     450
     451                        inline reference       front() { NV_ASSERT( !Super::empty(), "front() called on empty data!" );  return Super::data()[0]; }
     452                        inline const_reference front() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[0]; }
     453                        inline reference       back() { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[Super::size() - 1]; }
     454                        inline const_reference back() const { NV_ASSERT( !Super::empty(), "front() called on empty data!" ); return Super::data()[Super::size() - 1]; }
     455
     456                        reference operator[]( size_type i )
     457                        {
     458                                NV_ASSERT( i < Super::size(), "Out of range" );
     459                                return Super::data()[i];
     460                        }
     461
     462                        const_reference operator[]( size_type i ) const
     463                        {
     464                                NV_ASSERT( i < Super::size(), "Out of range" );
     465                                return Super::data()[i];
     466                        }
     467
     468                        inline void fill( const value_type& value )
     469                        {
     470                                fill_n( iterator( Super::data() ), iterator( Super::data() + this->size() ), value );
     471                        }
     472
    426473                };
    427474
    428475        }
    429476
    430         class const_mem_ref : public detail::data_base< const_storage_view< char > >
    431         {
     477        class const_mem_ref : public detail::add_iterators< const_storage_view< char > >
     478        {
     479                typedef detail::add_iterators< const_storage_view< char > > inherited;
    432480        public:
    433481                typedef char                 value_type;
     
    440488                typedef const_pointer        const_iterator;
    441489        public:
    442                 inline const_mem_ref() : detail::data_base< const_storage_view< char > >() {}
    443                 inline const_mem_ref( const void* p, size_type n ) : detail::data_base< const_storage_view< char > >( (const char*)p, n ) {}
    444                 inline const_mem_ref( const const_mem_ref& l ) : detail::data_base< const_storage_view< char > >( l.data(), l.size() ) {}
    445         };
    446 
    447         class mem_ref : public detail::data_base< storage_view< char > >
    448         {
     490                inline const_mem_ref() : inherited() {}
     491                inline const_mem_ref( const void* p, size_type n ) : inherited( (const char*)p, n ) {}
     492                inline const_mem_ref( const const_mem_ref& l ) : inherited( l.data(), l.size() ) {}
     493        };
     494
     495        class mem_ref : public detail::add_iterators< storage_view< char > >
     496        {
     497                typedef detail::add_iterators< storage_view< char > > inherited;
    449498        public:
    450499                typedef char                 value_type;
     
    458507                typedef const_pointer        const_iterator;
    459508        public:
    460                 inline mem_ref() : detail::data_base< storage_view< char > >() {}
    461                 inline mem_ref( void* p, size_type n ) : detail::data_base< storage_view< char > >( (char*)p, n ) {}
    462                 inline mem_ref( const mem_ref& l ) : detail::data_base< storage_view< char > >( const_cast< char* >( l.data() ), l.size() ) {}
     509                inline mem_ref() : inherited() {}
     510                inline mem_ref( void* p, size_type n ) : inherited( (char*)p, n ) {}
     511                inline mem_ref( const mem_ref& l ) : inherited( const_cast< char* >( l.data() ), l.size() ) {}
     512        };
     513
     514        template< typename SizeType >
     515        struct default_next_capacity
     516        {
     517                static SizeType get( SizeType requested, SizeType capacity )
     518                {
     519                        SizeType additional = nv::max( requested, capacity );
     520                        return capacity + additional;
     521                }
    463522        };
    464523
     
    468527                static void initialize( ForwardIterator first, ForwardIterator last )
    469528                {
    470                         uninitialized_construct( first, last );
     529                        typedef typename iterator_traits< ForwardIterator >::value_type value_type;
     530                        uninitialized_construct( first, last, value_type() );
     531                }
     532                template < typename InputIterator, typename ForwardIterator >
     533                static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
     534                {
     535                        return uninitialized_copy( first, last, out );
     536                }
     537                template < typename ForwardIterator >
     538                static void destroy( ForwardIterator first, ForwardIterator last )
     539                {
     540                        uninitialized_destroy( first, last );
    471541                }
    472542        };
     
    476546                template < typename ForwardIterator >
    477547                static void initialize( ForwardIterator, ForwardIterator )
     548                {
     549                }
     550                template < typename InputIterator, typename ForwardIterator >
     551                static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
     552                {
     553                        return detail::uninitialized_copy( first, last, out, true_type );
     554                }
     555                template < typename ForwardIterator >
     556                static void destroy( ForwardIterator, ForwardIterator )
    478557                {
    479558                }
     
    489568                                detail::uninitialized_construct_impl( first, last, false_type() );
    490569                }
    491         };
    492 
     570                template < typename InputIterator, typename ForwardIterator >
     571                static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out )
     572                {
     573                        return uninitialized_copy( first, last, out );
     574                }
     575                template < typename ForwardIterator >
     576                static void destroy( ForwardIterator first, ForwardIterator last )
     577                {
     578                        typedef typename iterator_traits< ForwardIterator >::value_type value_type;
     579                        if ( !has_trivial_destructor<value_type>() )
     580                                detail::uninitialized_destroy_impl( first, last, false_type() );
     581                }
     582        };
     583
     584        template< typename T >
     585        class dynamic_storage
     586        {
     587        public:
     588                typedef T      value_type;
     589
     590                static constexpr bool is_static   = false;
     591                static constexpr bool is_const    = false;
     592                static constexpr size_t type_size = sizeof( value_type );
     593
     594                constexpr dynamic_storage() : m_data( nullptr ) {}
     595
     596                constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); }
     597                inline    value_type* data() { return reinterpret_cast<T*>( m_data ); }
     598                constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
     599                inline    char* raw_data() { return reinterpret_cast<char*>( m_data ); }
     600        protected:
     601                bool reallocate( size_t new_size )
     602                {
     603                        if ( m_data != 0 || new_size != 0 )
     604                                m_data = (uint8*)nvrealloc( m_data, new_size * sizeof( value_type ) );
     605                        return true; // TODO : alloc check?
     606                }
     607        protected:
     608                uint8* m_data;
     609        };
     610
     611        template< typename T, size_t N >
     612        class static_storage
     613        {
     614        public:
     615                typedef T      value_type;
     616
     617                static constexpr bool is_static   = true;
     618                static constexpr bool is_const    = false;
     619                static constexpr size_t type_size = sizeof( value_type );
     620
     621                constexpr const value_type* data() const { return reinterpret_cast<const value_type*>( m_data ); }
     622                inline    value_type* data() { return reinterpret_cast<T*>( m_data ); }
     623                constexpr const char* raw_data() const { return reinterpret_cast<const char*>( m_data ); }
     624                inline    char* raw_data() { return reinterpret_cast<char*>( m_data ); }
     625        protected:
     626                static constexpr bool reallocate( size_t new_size ) { return new_size <= N; }
     627        protected:
     628                typedef aligned_array_t<T, N, alignof( T ) > storage_type;
     629                storage_type m_data;
     630        };
     631
     632        template< typename Storage, size_t N >
     633        class fixed_storage : public Storage
     634        {
     635        public:
     636                typedef size_t size_type;
     637
     638                static constexpr bool is_fixed = true;
     639
     640                fixed_storage()
     641                {
     642                        Storage::reallocate( N );
     643                }
     644                ~fixed_storage()
     645                {
     646                        Storage::reallocate( 0 );
     647                }
     648                static constexpr size_t capacity() { return N; }
     649                static constexpr size_t size() { return N; }
     650                static constexpr bool empty() { return N != 0; }
     651                static constexpr size_t raw_size() { return sizeof( T ) * N; }
     652        };
     653
     654        template< typename Storage >
     655        class resizable_storage : public Storage
     656        {
     657        public:
     658                typedef size_t size_type;
     659
     660                static constexpr bool is_fixed = false;
     661
     662                ~resizable_storage()
     663                {
     664                        if ( m_size > 0 ) reallocate( 0 );
     665                }
     666                constexpr size_t capacity() { return m_size; }
     667                constexpr size_t size() const { return m_size; }
     668                constexpr bool empty() const { return m_size != 0; }
     669                constexpr size_t raw_size() const { return sizeof( value_type ) * m_size; }
     670        protected:
     671                constexpr resizable_storage() : m_size( 0 ) {}
     672                // TODO: return type error checking
     673                bool resize( size_t new_size )
     674                {
     675                        if ( new_size != m_size )
     676                        {
     677                                m_size = new_size;
     678                                return reallocate( m_size );
     679                        }
     680                        return true;
     681                }
     682        protected:
     683                size_type m_size;
     684        };
     685
     686
     687        template< typename T, size_t N >
     688        using fixed_static_storage  = fixed_storage< static_storage< T, N >, N >;
     689
     690        template< typename T, size_t N >
     691        using fixed_dynamic_storage = fixed_storage< dynamic_storage< T >, N >;
     692
     693        template< typename T >
     694        using resizable_dynamic_storage = resizable_storage< dynamic_storage< T > >;
     695
     696// TODO:
     697//      template< typename T, size_t N >
     698//      using resizable_static_storage  = resizable_storage< static_storage< T, N > >;
     699
     700// TODO:
     701//      template< typename Storage, typename NextCapacity = default_next_capacity >
     702//      class growable_storage : Storage;
    493703
    494704        template <
     
    496706                typename InitializePolicy = policy_initialize_standard
    497707        >
    498         class fixed_container_storage
    499         {
    500         public:
    501                 typedef typename Storage::value_type   value_type;
    502 
    503                 static const bool   is_static  = Storage::is_static;
    504                 static const bool   is_fixed   = Storage::is_fixed;
    505                 static const bool   is_const   = Storage::is_const;
    506                 static const size_t type_size  = sizeof( value_type );
    507 
    508                 fixed_container_storage()
    509                 {
    510                         InitializePolicy::initialize( data(), data() + m_data.capacity() );
    511                 }
    512 
    513                 ~fixed_container_storage()
    514                 {
    515                         uninitialized_destroy( data(), data() + m_data.capacity() );
    516                 }
    517 
    518                 static NV_CONSTEXPR size_t capacity() { return Storage::capacity(); }
    519                 static NV_CONSTEXPR size_t size() { return Storage::capacity(); }
    520                 NV_CONSTEXPR value_type* data() { return m_data.data(); }
    521                 NV_CONSTEXPR const value_type* data() const { return m_data.data(); }
    522         protected:
    523                 Storage m_data;
    524         };
    525 
    526         template < typename T >
    527         class dynamic_container_allocator
    528         {
    529         public:
    530                 static const bool   is_static = false;
    531                 static const bool   is_fixed  = true;
    532                 static const size_t type_size = sizeof( T );
    533 
    534                 dynamic_container_allocator()
    535                         : m_data(nullptr), m_size(0)
    536                 {
    537                
    538                 }
    539 
    540                 static NV_CONSTEXPR size_t capacity() { return 0x80000000; }
    541                 size_t size() const { return m_size; }
    542                 T* data() { return static_cast<T*>( m_data ); }
    543                 const T* data() const { return static_cast<const T*>( m_data ); }
    544 
    545                 ~dynamic_container_allocator()
    546                 {
    547                         delete m_data;
    548                 }
    549 
    550                 uint8* m_data;
    551                 size_t m_size;
     708        class fixed_container_allocator : public Storage
     709        {
     710        public:
     711                typedef typename Storage::value_type value_type;
     712                typedef typename Storage::size_type  size_type;
     713
     714                fixed_container_allocator()
     715                {
     716                        InitializePolicy::initialize( data(), data() + Storage::capacity() );
     717                }
     718
     719                ~fixed_container_allocator()
     720                {
     721                        InitializePolicy::destroy( data(), data() + Storage::capacity() );
     722                }
     723        };
     724
     725        template <
     726                typename Storage,
     727                typename InitializePolicy = policy_initialize_standard
     728        >
     729        class sized_container_allocator : public Storage
     730        {
     731        public:
     732                typedef typename Storage::value_type value_type;
     733                typedef typename Storage::size_type  size_type;
     734
     735                sized_container_allocator() {}
     736                explicit sized_container_allocator( size_type new_size ) { resize( new_size ); }
     737
     738                void resize( size_type new_size )
     739                {
     740                        size_type old_size = Storage::size();
     741                        if ( new_size != old_size )
     742                        {
     743                                if ( new_size < old_size )
     744                                {
     745                                        InitializePolicy::destroy( Storage::data() + new_size, Storage::data() + old_size );
     746                                }
     747                                Storage::resize( new_size );
     748                                if ( new_size > old_size )
     749                                {
     750                                        InitializePolicy::initialize( Storage::data() + old_size, Storage::data() + new_size );
     751                                }
     752                        }
     753                }
     754
     755                void assign( const value_type* ptr, size_type sz )
     756                {
     757                        if ( Storage::size() > 0 ) InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() );
     758                        if ( ptr != nullptr && sz > 0 )
     759                        {
     760                                if ( sz != Storage::size() )
     761                                {
     762                                        Storage::resize( 0 );
     763                                        Storage::resize( sz );
     764                                }
     765                                InitializePolicy::copy( ptr, ptr + sz, Storage::data() );
     766                        }
     767                        else Storage::resize( 0 );
     768                }
     769
     770                void clear()
     771                {
     772                        if ( Storage::size() > 0 )
     773                        {
     774                                InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::size() );
     775                                Storage::resize( 0 );
     776                        }
     777                }
     778
     779                ~sized_container_allocator()
     780                {
     781                        if ( Storage::size() > 0 ) clear();
     782                }
     783
    552784        };
    553785
  • trunk/nv/stl/rtti_support.hh

    r381 r382  
    2222        static const char* name() { return #T; } \
    2323        static nv::uint64 hash() { \
    24                 static const nv::uint64 value = nv::rtti_hash(#T); \
     24NV_MSVC_SUPRESS( 4307 )\
     25                static const nv::uint64 value = nv::rtti_const_hash(#T); \
    2526                return value; \
    2627        } \
     
    3233        static const char* name() { return NAME; } \
    3334        static nv::uint64 hash() { \
    34                 static const nv::uint64 value = nv::rtti_hash(#T); \
     35NV_MSVC_SUPRESS( 4307 )\
     36                static const nv::uint64 value = nv::rtti_const_hash(#T); \
    3537                return value; \
    3638                                } \
     
    4244        namespace detail
    4345        {
    44 //              static NV_CONSTEXPR unsigned long long rtti_hash_basis = 14695981039346656037ULL;
    45 //              static NV_CONSTEXPR unsigned long long rtti_hash_prime = 1099511628211ULL;
    46                 static unsigned long long rtti_hash_basis = 14695981039346656037ULL;
    47                 static unsigned long long rtti_hash_prime = 1099511628211ULL;
     46                static constexpr unsigned long long rtti_hash_basis = 14695981039346656037ULL;
     47                static constexpr unsigned long long rtti_hash_prime = 1099511628211ULL;
    4848
    49 //              constexpr uint64 rtti_hash_impl( char c, const char* remain, uint64 value )
    50 //              {
    51 //                      return c == 0 ? value : rtti_hash_impl( remain[0], remain + 1, ( value ^ (uint64)c ) * rtti_hash_prime );
    52 //              }
     49                constexpr uint64 rtti_hash_impl( char c, const char* remain, uint64 value )
     50                {
     51                        return c == 0 ? value : rtti_hash_impl( remain[0], remain + 1, (uint64)(uint64)( value ^ (uint64)c ) * rtti_hash_prime );
     52                }
    5353
    5454                template < typename T > struct rtti_type_fail { static const bool value = false; };
    5555        }
    5656
    57 //      // compile-time hash
    58 //      constexpr uint64 rtti_const_hash( const char* str )
    59 //      {
    60 //              return detail::hash_impl( str[0], str + 1, detail::hash_basis );
    61 //      }
     57        // compile-time hash
     58        constexpr uint64 rtti_const_hash( const char* str )
     59        {
     60                return detail::rtti_hash_impl( str[0], str + 1, detail::rtti_hash_basis );
     61        }
    6262
    6363        // run-time hash
  • trunk/nv/stl/string.hh

    r381 r382  
    5959
    6060        // string base class - will become a base for a string class later
    61         class string_base : public detail::data_base< const_storage_view< char > >
    62         {
     61        class string_base : public detail::add_iterators< const_storage_view< char > >
     62        {
     63                typedef detail::add_iterators< const_storage_view< char > > inherited;
    6364        public:
    6465                typedef char           value_type;
     
    7172                typedef ptrdiff_t      difference_type;
    7273
    73                 static NV_CONSTEXPR_CONST size_type npos = size_type( -1 );
     74                static constexpr size_type npos = size_type( -1 );
    7475
    7576                // conversion to std::string
     
    7980                }
    8081
    81                 inline NV_CONSTEXPR size_type length()   const { return size(); }
     82                inline size_type length()   const { return size(); }
    8283
    8384                // access
    84                 inline NV_CONSTEXPR char operator[]( size_type i ) const { return data()[i]; }
     85                inline char operator[]( size_type i ) const { return data()[i]; }
    8586                inline char at( size_type i ) const
    8687                {
     
    8990                }
    9091
    91                 inline NV_CONSTEXPR char front()        const { return data()[0]; }
    92                 inline NV_CONSTEXPR char back()         const { return data()[size() - 1]; }
     92                inline char front()        const { return data()[0]; }
     93                inline char back()         const { return data()[size() - 1]; }
    9394
    9495                // string operations
     
    194195                // Literal constructors
    195196                template< size_t N >
    196                 inline string_base( char( &s )[N] ) : detail::data_base< const_storage_view< char > >( s, N - 1 ) {}
     197                inline string_base( char( &s )[N] ) : inherited( s, N - 1 ) {}
    197198                template< size_t N >
    198                 inline string_base( const char( &s )[N] ) : detail::data_base< const_storage_view< char > >( s, N - 1 ) {}
     199                inline string_base( const char( &s )[N] ) : inherited( s, N - 1 ) {}
    199200
    200201        protected:
    201                 inline NV_CONSTEXPR string_base() : detail::data_base< const_storage_view< char > >() {}
    202                 inline NV_CONSTEXPR string_base( pointer a_data, size_type a_lenght )
    203                         : detail::data_base< const_storage_view< char > >( a_data, a_lenght ) {}
     202                inline string_base() {}
     203                inline string_base( pointer a_data, size_type a_lenght ) : inherited( a_data, a_lenght ) {}
    204204
    205205                template < typename ReverseIterator >
     
    213213        {
    214214        public:
    215                 inline NV_CONSTEXPR string_ref() {}
    216                 inline NV_CONSTEXPR string_ref( const string_ref& rhs )
     215                inline string_ref() {}
     216                inline string_ref( const string_ref& rhs )
    217217                        : string_base( rhs.data(), rhs.size() )
    218218                {
    219219                }
    220                 inline NV_CONSTEXPR string_ref( const string_base& rhs )
     220                inline string_ref( const string_base& rhs )
    221221                        : string_base( rhs.data(), rhs.size() )
    222222                {
     
    228228                }
    229229
    230                 inline NV_CONSTEXPR string_ref( const char* str, size_type len )
     230                inline string_ref( const char* str, size_type len )
    231231                        : string_base( str, len )
    232232                {
     
    277277        {
    278278        public:
    279                 NV_CONSTEXPR const_string() {}
    280                 const_string( const char* str, size_type len )
     279                inline const_string() {}
     280                inline const_string( const char* str, size_type len )
    281281                {
    282282                        initialize( str, len );
    283283                }
    284                 explicit const_string( const char* str )
     284                inline explicit const_string( const char* str )
    285285                {
    286286                        initialize( str, nvstrlen( str ) );
  • trunk/nv/stl/traits/alignment.hh

    r377 r382  
    8686        using aligned_array_t = typename aligned_array< T, Size, Align >::type;
    8787
    88         template< size_t Size, size_t Align = NV_ALIGN_OF( max_align_t ) >
     88        template< size_t Size, size_t Align = alignof( max_align_t ) >
    8989        struct aligned_storage
    9090        {
     
    9595        };
    9696
    97         template< size_t Size, size_t Align = NV_ALIGN_OF( max_align_t ) >
     97        template< size_t Size, size_t Align = alignof( max_align_t ) >
    9898        using aligned_storage_t = typename aligned_storage<Size, Align>::type;
    9999
     
    106106                struct size_max < >
    107107                {
    108                         static const size_t value = 0;
     108                        static constexpr size_t value = 0;
    109109                };
    110110
     
    112112                struct size_max < Size >
    113113                {
    114                         static const size_t value = Size;
     114                        static constexpr size_t value = Size;
    115115                };
    116116
     
    122122        struct aligned_union
    123123        {
    124                 static const size_t max_length = detail::size_max < Size, sizeof( Types )... >::value;
    125                 static const size_t alignment_value = detail::size_max < alignment_of< Types >::value... >::value;
     124                static constexpr size_t max_length = detail::size_max < Size, sizeof( Types )... >::value;
     125                static constexpr size_t alignment_value = detail::size_max < alignment_of< Types >::value... >::value;
    126126                struct type
    127127                {
  • trunk/nv/stl/traits/common.hh

    r381 r382  
    2121        struct integral_constant
    2222        {
    23                 static const T value = VALUE;
     23                static constexpr T value = VALUE;
    2424                typedef T value_type;
    2525                typedef integral_constant<T, VALUE> type;
    26                 NV_CONSTEXPR operator value_type() const NV_NOEXCEPT{ return ( value ); }
    27                 NV_CONSTEXPR value_type operator()() const NV_NOEXCEPT{ return value; }
     26                constexpr operator value_type() const noexcept { return value; }
     27                constexpr value_type operator()() const noexcept { return value; }
    2828        };
    2929
     
    169169
    170170        template< typename T >
    171         inline typename remove_reference<T>::type&& move( T&& arg ) NV_NOEXCEPT
     171        constexpr typename remove_reference<T>::type&& move( T&& arg ) noexcept
    172172        {
    173173                return ( ( typename remove_reference<T>::type&& )arg );
     
    175175
    176176        template < typename T >
    177         inline T&& forward( typename remove_reference<T>::type& t )
     177        constexpr T&& forward( typename remove_reference<T>::type& t )
    178178        {
    179179                return static_cast<T&&>( t );
    180180        }
    181181
    182                 template < typename T >
    183         inline T&& forward( typename remove_reference<T>::type&& t ) NV_NOEXCEPT
     182        template < typename T >
     183        constexpr T&& forward( typename remove_reference<T>::type&& t ) noexcept
    184184        {
    185185                static_assert( !is_lvalue_reference<T>::value, "Can not forward an rvalue as an lvalue." );
  • trunk/nv/stl/traits/function.hh

    r377 r382  
    3535                        typedef R        return_type;
    3636                        typedef void     class_type;
    37                         static const int arg_count = 0;
     37                        static constexpr int arg_count = 0;
    3838                };
    3939
     
    4444                        typedef R        return_type;
    4545                        typedef void     class_type;
    46                         static const int arg_count = sizeof...( Args );
     46                        static constexpr int arg_count = sizeof...( Args );
    4747                };
    4848
     
    5353                        typedef R       return_type;
    5454                        typedef C       class_type;
    55                         static const int arg_count = 0;
     55                        static constexpr int arg_count = 0;
    5656                };
    5757
     
    6262                        typedef R        return_type;
    6363                        typedef C        class_type;
    64                         static const int arg_count = sizeof...( Args );
     64                        static constexpr int arg_count = sizeof...( Args );
    6565                };
    6666
  • trunk/nv/stl/traits/properties.hh

    r378 r382  
    260260
    261261        template< typename T >
    262         struct alignment_of     : integral_constant < size_t, NV_ALIGN_OF( typename remove_reference< T >::type ) > {};
     262        struct alignment_of     : integral_constant < size_t, alignof( typename remove_reference< T >::type ) > {};
    263263
    264264        template < typename T >
  • trunk/nv/stl/traits/transforms.hh

    r377 r382  
    8888                {
    8989                private:
    90                         static const bool size1test = sizeof( T ) <= sizeof( signed char );
    91                         static const bool size2test = sizeof( T ) <= sizeof( signed short );
    92                         static const bool size4test = sizeof( T ) <= sizeof( signed int );
     90                        static constexpr bool size1test = sizeof( T ) <= sizeof( signed char );
     91                        static constexpr bool size2test = sizeof( T ) <= sizeof( signed short );
     92                        static constexpr bool size4test = sizeof( T ) <= sizeof( signed int );
    9393                        typedef conditional_t<size4test, signed int, signed long> test4type;
    9494                        typedef conditional_t<size2test, signed short, test4type> test2type;
     
    113113                {
    114114                private:
    115                         static const bool size1test = sizeof( T ) <= sizeof( unsigned char );
    116                         static const bool size2test = sizeof( T ) <= sizeof( unsigned short );
    117                         static const bool size4test = sizeof( T ) <= sizeof( unsigned int );
     115                        static constexpr bool size1test = sizeof( T ) <= sizeof( unsigned char );
     116                        static constexpr bool size2test = sizeof( T ) <= sizeof( unsigned short );
     117                        static constexpr bool size4test = sizeof( T ) <= sizeof( unsigned int );
    118118                        typedef conditional_t<size4test, unsigned int, unsigned long> test4type;
    119119                        typedef conditional_t<size2test, unsigned short, test4type> test2type;
  • trunk/nv/stl/utility.hh

    r377 r382  
    2020{
    2121
    22         // TODO: change to swap once you get rid of STL
    23         template< typename T >
    24         void swap( T& x, T& y )
     22        // TODO: change to swap<T> once you get rid of STL
     23        template< typename T, typename U >
     24        void swap( T& x, U& y )
    2525        {
    2626                T t = move( x );
  • trunk/src/engine/particle_engine.cc

    r374 r382  
    368368                                {
    369369                                        edata.emmiter_func = nv_particle_emmiter_point;
    370                                         NV_LOG_WARNING( "Unknown emmiter type in particle system! (", sub_type, ")" );
     370                                        NV_LOG_WARNING( "Unknown emmiter type in particle system! (", sub_type.c_str(), ")" );
    371371                                }
    372372
  • trunk/src/engine/program_manager.cc

    r380 r382  
    3737        }
    3838
    39         nv::program program = m_context->get_device()->create_program( vsource, fsource );
     39        nv::program program = m_context->get_device()->create_program( string_ref( vsource ), string_ref( fsource ) );
    4040        return add( program );
    4141}
  • trunk/src/engine/resource_system.cc

    r380 r382  
    1212{
    1313        m_lua = a_lua_state;
    14         lua::register_storage( m_lua, get_storage_name(), "register_" + get_resource_name().to_string() );
     14        lua::register_storage( m_lua, get_storage_name(), string_ref( "register_" + get_resource_name().to_string() ) );
    1515}
    1616
  • trunk/src/formats/assimp_loader.cc

    r380 r382  
    238238                        aiMesh* mesh = scene->mMeshes[mc];
    239239
    240                         NV_LOG_NOTICE( "Mesh #", mc, "   - ", std::string( mesh->mName.data ) );
     240                        NV_LOG_NOTICE( "Mesh #", mc, "   - ", string_ref( (char*)mesh->mName.data ) );
    241241                        NV_LOG_NOTICE( "  bones   - ", mesh->mNumBones );
    242242                        NV_LOG_NOTICE( "  uvs     - ", mesh->mNumUVComponents[0] );
  • trunk/src/formats/obj_loader.cc

    r376 r382  
    280280                for ( nv::size_t a = 0; a < count; ++a )
    281281                {
    282                         const vec3& n = m_data[a].normal;
    283                         const vec3& t = tan1[a];
    284                         if ( ! (t.x == 0.0f && t.y == 0.0f && t.z == 0.0f) )
     282                        const vec3& nv = m_data[a].normal;
     283                        const vec3& tv = tan1[a];
     284                        if ( ! (tv.x == 0.0f && tv.y == 0.0f && tv.z == 0.0f) )
    285285                        {
    286                                 m_data[a].tangent    = vec4( glm::normalize(t - n * glm::dot( n, t )), 0.0f );
    287                                 m_data[a].tangent[3] = (glm::dot(glm::cross(n, t), tan2[a]) < 0.0f) ? -1.0f : 1.0f;
     286                                m_data[a].tangent    = vec4( glm::normalize(tv - nv * glm::dot( nv, tv )), 0.0f );
     287                                m_data[a].tangent[3] = (glm::dot(glm::cross(nv, tv), tan2[a]) < 0.0f) ? -1.0f : 1.0f;
    288288                        }
    289289                }
  • trunk/src/stl/string.cc

    r380 r382  
    5050        *s = '\0';
    5151        string_reverse( str, s - 1 );
    52         return (size_t)( s - str );
     52        return (nv::size_t)( s - str );
    5353}
    5454
     
    6565        *s = '\0';
    6666        string_reverse( str, s - 1 );
    67         return (size_t)( s - str );
     67        return (nv::size_t)( s - str );
    6868}
    6969
     
    7878        *s = '\0';
    7979        string_reverse( str, s - 1 );
    80         return (size_t)( s - str );
     80        return (nv::size_t)( s - str );
    8181}
    8282
Note: See TracChangeset for help on using the changeset viewer.