Changeset 401
- Timestamp:
- 06/13/15 18:02:17 (10 years ago)
- Location:
- trunk
- Files:
-
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/base/common.hh
r397 r401 131 131 #if NV_COMPILER == NV_MSVC 132 132 #define NV_DEPRECATED(func) __declspec(deprecated) func 133 #define NV_ALIGN(value) __declspec(align(value))134 #define NV_ALIGNED_STRUCT(value) __declspec(align(value)) struct135 133 #define NV_NOALIAS __declspec(noalias) 136 134 #define NV_RESTRICT __declspec(restrict) 137 135 #define NV_RESTRICT_VAR __restrict 136 #define NV_MSVC_SUPRESS( warn_number ) __pragma( warning( suppress : warn_number ) ) 138 137 #if NV_ARCHITECTURE == NV_64BIT 139 138 #define NV_OFFSET_OF(obj,m) (nv::size_t)( (nv::ptrdiff_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m)) ) 140 139 #else // NV_32BIT 141 140 #define NV_OFFSET_OF(obj,m) (nv::size_t)&reinterpret_cast<const volatile char&>((((obj *)0)->m)) 142 #define NV_MSVC_SUPRESS( warn_number ) __pragma( warning( suppress : warn_number ) )143 141 #endif 144 142 #elif NV_COMPILER == NV_GNUC || NV_COMPILER == NV_CLANG 145 143 #define NV_DEPRECATED(func) func __attribute__ ((deprecated)) 146 #define NV_ALIGN(value) __attribute__((aligned(value)))147 #define NV_ALIGNED_STRUCT(value) struct __attribute__((aligned(value)))148 144 #define NV_RESTRICT __restrict__ 149 145 #define NV_RESTRICT_VAR __restrict__ … … 201 197 using ::size_t; 202 198 #else 203 using size_t = decltype( 0);199 using size_t = decltype( sizeof(0) ); 204 200 #endif 205 201 using ptrdiff_t = decltype((int*)0 - (int*)0); … … 271 267 } // namespace nv 272 268 269 static_assert( nv::size_t( -1 ) > 0, "size_t is signed!" ); 270 static_assert( sizeof( nv::size_t ) >= 4, "size_t is smaller than 4 bytes!" ); 273 271 static_assert( sizeof( nv::sint8 ) == 1, "sint8 size isn't 1 bytes" ); 274 272 static_assert( sizeof( nv::sint16 ) == 2, "sint16 size isn't 2 bytes" ); -
trunk/nv/base/new.hh
r396 r401 23 23 } 24 24 #endif 25 #else 26 #include <new> 25 27 #endif 26 28 -
trunk/nv/common.hh
r396 r401 10 10 #include <nv/base/common.hh> 11 11 12 #endif NV_COMMON_HH12 #endif // NV_COMMON_HH -
trunk/nv/gfx/animation.hh
r395 r401 60 60 uint32 mod = 0; 61 61 if ( desc.slots[0].vslot == animation_slot::TIME ) mod = 1; 62 std::copy_n( fdata + mod, keyfsize - mod, result );62 raw_copy_n( fdata + mod, keyfsize - mod, result ); 63 63 return keyfsize - mod; 64 64 } … … 82 82 if ( count == 1 ) 83 83 { 84 std::copy_n( fdata + 1, keyfresult, result );84 raw_copy_n( fdata + 1, keyfresult, result ); 85 85 return keyfresult; 86 86 } … … 100 100 if ( count == 1 ) 101 101 { 102 std::copy_n( fdata, keyfresult, result );102 raw_copy_n( fdata, keyfresult, result ); 103 103 return keyfresult; 104 104 } -
trunk/nv/stl/algorithm/copy.hh
r395 r401 17 17 #include <nv/stl/algorithm/raw.hh> 18 18 #include <nv/stl/iterator.hh> 19 #include <nv/stl/type_traits/ common.hh>19 #include <nv/stl/type_traits/properties.hh> 20 20 21 21 namespace nv … … 35 35 inline BlockAccessIterator copy_impl( BlockAccessIterator first, BlockAccessIterator last, OutputIterator out, true_type, block_access_iterator_tag, block_access_iterator_tag ) 36 36 { 37 return raw_alias_copy( first, last, out ) 37 return raw_alias_copy( first, last, out ); 38 38 } 39 39 … … 48 48 inline BlockAccessIterator copy_n_impl( BlockAccessIterator first, BlockAccessIterator n, OutputIterator out, true_type, block_access_iterator_tag, block_access_iterator_tag ) 49 49 { 50 return raw_alias_copy_n( first, n, out ) 50 return raw_alias_copy_n( first, n, out ); 51 51 } 52 52 } … … 59 59 typedef typename iterator_traits< OutputIterator >::iterator_category output_iterator_category; 60 60 return detail::copy_impl( first, last, out, 61 has_trivial_copy<value_type>::value, i terator_category(), output_iterator_category() );61 has_trivial_copy<value_type>::value, input_iterator_category(), output_iterator_category() ); 62 62 } 63 63 … … 69 69 typedef typename iterator_traits< OutputIterator >::iterator_category output_iterator_category; 70 70 return detail::copy_n_impl( first, n, out, 71 has_trivial_copy<value_type>::value, i terator_category(), output_iterator_category() );71 has_trivial_copy<value_type>::value, input_iterator_category(), output_iterator_category() ); 72 72 } 73 73 -
trunk/nv/stl/algorithm/fill.hh
r395 r401 70 70 { 71 71 // TODO: version with T temp = T() for scalars 72 for ( ; n-- > 0; ++first ) *first = value;72 for ( ; n-- > 0; ++first ) *first = T(); 73 73 return first; 74 74 } … … 77 77 BlockAccessIterator fill_default_n_impl( BlockAccessIterator first, size_t count, true_type, block_access_iterator_tag ) 78 78 { 79 return BlockAccessIterator( raw_zero_n( first, count , (unsigned char)value) );79 return BlockAccessIterator( raw_zero_n( first, count ) ); 80 80 } 81 81 } -
trunk/nv/stl/container/contiguous_storage.hh
r396 r401 49 49 ~static_storage() = default; 50 50 protected: 51 typedef aligned_array_t<T, N, alignof( T ) > storage_type; 52 storage_type m_data; 51 alignas( T ) unsigned char m_data[ N * sizeof( N ) ]; 53 52 }; 54 53 -
trunk/nv/stl/container/contiguous_storage_policy.hh
r399 r401 63 63 ~resizable_storage() 64 64 { 65 if ( m_size > 0 ) reallocate( 0, false );65 if ( m_size > 0 ) Storage::reallocate( 0, false ); 66 66 } 67 67 static constexpr size_type max_size() { return size_type( 0x80000000 ); } … … 85 85 { 86 86 m_size = other.m_size; 87 Storage::operator=( nv::move( o ) );87 Storage::operator=( nv::move( other ) ); 88 88 other.m_size = 0; 89 89 return *this; … … 95 95 if ( new_size != m_size ) 96 96 { 97 if ( reallocate( new_size, copy_needed ) )97 if ( Storage::reallocate( new_size, copy_needed ) ) 98 98 { 99 99 m_size = new_size; … … 132 132 ~growable_storage() 133 133 { 134 if ( m_capacity > 0 ) reallocate( 0, false );134 if ( m_capacity > 0 ) Storage::reallocate( 0, false ); 135 135 } 136 136 static constexpr size_type max_size() { return size_type( 0x80000000 ); } … … 169 169 { 170 170 size_type new_capacity = NextCapacity::get( new_size - m_capacity, m_capacity, max_size() ); 171 if ( new_capacity > 0 && reallocate( new_capacity, true ) )171 if ( new_capacity > 0 && Storage::reallocate( new_capacity, true ) ) 172 172 { 173 173 m_capacity = new_capacity; … … 184 184 if ( new_capacity > m_capacity ) 185 185 { 186 if ( reallocate( new_capacity, copy_needed ) )186 if ( Storage::reallocate( new_capacity, copy_needed ) ) 187 187 { 188 188 m_capacity = new_capacity; -
trunk/nv/stl/container/fixed_container_handler.hh
r395 r401 32 32 fixed_container_handler() 33 33 { 34 InitializePolicy::initialize( data(),data() + Storage::capacity() );34 InitializePolicy::initialize( Storage::data(), Storage::data() + Storage::capacity() ); 35 35 } 36 36 37 37 explicit fixed_container_handler( default_init ) 38 38 { 39 uninitialized_construct( data(),data() + Storage::capacity() );39 uninitialized_construct( Storage::data(), Storage::data() + Storage::capacity() ); 40 40 } 41 41 42 42 explicit fixed_container_handler( const value_type& v ) 43 43 { 44 uninitialized_fill( data(),data() + Storage::capacity(), v );44 uninitialized_fill( Storage::data(), Storage::data() + Storage::capacity(), v ); 45 45 } 46 46 47 47 ~fixed_container_handler() 48 48 { 49 InitializePolicy::destroy( data(),data() + Storage::capacity() );49 InitializePolicy::destroy( Storage::data(), Storage::data() + Storage::capacity() ); 50 50 } 51 51 -
trunk/nv/stl/container/growing_container_handler.hh
r395 r401 27 27 class growing_container_handler : public sized_container_handler< Storage, InitializePolicy > 28 28 { 29 typedef sized_container_handler< Storage, InitializePolicy > inherited;30 29 public: 31 30 typedef typename Storage::value_type value_type; … … 40 39 void push_back( const value_type& e ) 41 40 { 42 if ( Storage::try_grow( 1 ) ) copy_construct_object( data() +size() - 1, e );41 if ( Storage::try_grow( 1 ) ) copy_construct_object( Storage::data() + Storage::size() - 1, e ); 43 42 } 44 43 void push_back( value_type&& e ) 45 44 { 46 if ( Storage::try_grow( 1 ) ) move_construct_object( data() +size() - 1, forward<value_type>( e ) );45 if ( Storage::try_grow( 1 ) ) move_construct_object( Storage::data() + Storage::size() - 1, forward<value_type>( e ) ); 47 46 } 48 47 template < typename... Args > 49 48 void emplace_back( Args&&... args ) 50 49 { 51 if ( Storage::try_grow( 1 ) ) construct_object( data() +size() - 1, forward<Args>( args )... );50 if ( Storage::try_grow( 1 ) ) construct_object( Storage::data() + Storage::size() - 1, forward<Args>( args )... ); 52 51 } 53 52 void pop_back() 54 53 { 55 try_resize(size() - 1, true );54 Storage::try_resize( Storage::size() - 1, true ); 56 55 } 57 56 -
trunk/nv/stl/container/hash_table.hh
r395 r401 33 33 { 34 34 public: 35 typedef HashEntryPolicy base_type;36 typedef typename base_type::value_type 37 typedef typename base_type::entry_type 38 typedef typename base_type::hash_type 35 typedef HashEntryPolicy base_type; 36 typedef typename base_type::value_type value_type; 37 typedef typename base_type::entry_type entry_type; 38 typedef typename base_type::hash_type hash_type; 39 39 40 40 struct node_type : entry_type … … 72 72 typedef iterator_base< IsConst > base_type; 73 73 74 constexpr node_iterator() : iterator_base( nullptr ) {}75 constexpr node_iterator( const node_iterator& it ) : iterator_base( it.m_node ) {}74 constexpr node_iterator() : base_type( nullptr ) {} 75 constexpr node_iterator( const node_iterator& it ) : base_type( it.m_node ) {} 76 76 77 77 template < bool B, typename = enable_if_t< IsConst && !B > > 78 78 constexpr node_iterator( const node_iterator< B >& it ) 79 : iterator_base( it.m_node )79 : base_type( it.m_node ) 80 80 { 81 81 } … … 87 87 friend constexpr bool operator!=( const node_iterator& lhs, const node_iterator& rhs ) { return lhs.m_node != rhs.m_node; } 88 88 protected: 89 constexpr explicit node_iterator( node_type* node ) : iterator_base( node ) {}89 constexpr explicit node_iterator( node_type* node ) : base_type( node ) {} 90 90 91 91 template < typename T1, typename T2, typename T3 > … … 93 93 template < bool B > friend struct node_iterator; 94 94 95 inline void increment() { m_node =m_node->next; }95 inline void increment() { base_type::m_node = base_type::m_node->next; } 96 96 97 97 }; … … 103 103 104 104 constexpr table_iterator() 105 : iterator_base(), m_bucket( nullptr )105 : base_type(), m_bucket( nullptr ) 106 106 { 107 107 } 108 108 constexpr table_iterator( const table_iterator& other ) 109 : iterator_base( other ), m_bucket( other.m_bucket )109 : base_type( other ), m_bucket( other.m_bucket ) 110 110 { 111 111 } … … 113 113 template < bool B, typename = enable_if_t< IsConst && !B > > 114 114 constexpr table_iterator( const table_iterator< B >& it ) 115 : iterator_base( it.m_node ), m_bucket( it.m_bucket )115 : base_type( it.m_node ), m_bucket( it.m_bucket ) 116 116 { 117 117 } 118 118 119 119 table_iterator& operator++() { increment(); return *this; } 120 table_iterator operator++( int ) { bucket_iterator temp( *this ); increment(); return temp; }120 table_iterator operator++( int ) { table_iterator temp( *this ); increment(); return temp; } 121 121 122 122 friend constexpr bool operator==( const table_iterator& lhs, const table_iterator& rhs ) { return lhs.m_node == rhs.m_node; } … … 128 128 129 129 constexpr table_iterator( node_type* node, node_type** bucket ) 130 : iterator_base( node ), m_bucket( bucket )130 : base_type( node ), m_bucket( bucket ) 131 131 { 132 132 } 133 133 constexpr explicit table_iterator( node_type** bucket ) 134 : iterator_base( *bucket ), m_bucket( bucket )134 : base_type( *bucket ), m_bucket( bucket ) 135 135 { 136 136 } … … 140 140 ++m_bucket; 141 141 while ( *m_bucket == nullptr ) ++m_bucket; // Sentinel guarantees end 142 m_node = *m_bucket;142 base_type::m_node = *m_bucket; 143 143 } 144 144 145 145 void increment() 146 146 { 147 m_node =m_node->next;148 while ( m_node == nullptr )m_node = *++m_bucket; // Sentinel guarantees end147 base_type::m_node = base_type::m_node->next; 148 while ( base_type::m_node == nullptr ) base_type::m_node = *++m_bucket; // Sentinel guarantees end 149 149 } 150 150 node_type** m_bucket; … … 338 338 size_type bucket_index( hash_type hash_code, size_t b_count ) const 339 339 { 340 return RangeHashPolicy:: get<hash_type>( hash_code, b_count );340 return RangeHashPolicy::template get<hash_type>( hash_code, b_count ); 341 341 } 342 342 node_type** allocate_buckets( size_type new_count ) … … 408 408 typedef value_type& reference; 409 409 typedef const value_type& const_reference; 410 typedef value_type* pointer; 411 typedef const value_type* const_pointer; 410 412 411 413 typedef typename base_type::local_iterator local_iterator; … … 519 521 ++first; 520 522 } 521 return base_type::unconst( cend() );523 return base_type::unconst( this->cend() ); 522 524 } 523 525 -
trunk/nv/stl/container/hash_table_policy.hh
r395 r401 193 193 }; 194 194 195 constexpr bool entry_compare( const entry_type* entry, const key_type& key, hash_type ) 195 constexpr bool entry_compare( const entry_type* entry, const key_type& key, hash_type ) const 196 196 { 197 197 return base_type::compare( entry->value.first, key ); 198 198 } 199 199 200 constexpr bool entry_compare( const entry_type* entry, const value_type& value, hash_type ) 200 constexpr bool entry_compare( const entry_type* entry, const value_type& value, hash_type ) const 201 201 { 202 202 return base_type::compare( entry->value.first, value.first ); 203 203 } 204 204 205 inline void entry_construct( entry_type* entry, const value_type& value, hash_type ) 205 inline void entry_construct( entry_type* entry, const value_type& value, hash_type ) const 206 206 { 207 207 copy_construct_object( &(entry->value), value ); 208 208 } 209 209 210 constexpr hash_type get_entry_hash( const entry_type* entry ) 210 constexpr hash_type get_entry_hash( const entry_type* entry ) const 211 211 { 212 212 return base_type::get_hash( entry->value.first ); 213 213 } 214 constexpr hash_type get_value_hash( const value_type& value ) 214 constexpr hash_type get_value_hash( const value_type& value ) const 215 215 { 216 216 return base_type::get_hash( value.first ); … … 239 239 }; 240 240 241 constexpr bool entry_compare( const entry_type* entry, const key_type& key, hash_type h ) 241 constexpr bool entry_compare( const entry_type* entry, const key_type& key, hash_type h ) const 242 242 { 243 243 return entry->hash_code == h && base_type::compare( entry->value.first, key ); 244 244 } 245 constexpr bool entry_compare( const entry_type* entry, const value_type& value, hash_type h ) 245 constexpr bool entry_compare( const entry_type* entry, const value_type& value, hash_type h ) const 246 246 { 247 247 return entry->hash_code == h && base_type::compare( entry->value.first, value.first ); 248 248 } 249 249 250 constexpr hash_type get_entry_hash( const entry_type* entry ) 250 constexpr hash_type get_entry_hash( const entry_type* entry ) const 251 251 { 252 252 return entry->hash_code; 253 253 } 254 constexpr hash_type get_value_hash( const value_type& value ) 254 constexpr hash_type get_value_hash( const value_type& value ) const 255 255 { 256 256 return base_type::get_hash( value.first ); 257 257 } 258 inline void construct( entry_type* entry, const value_type& value, hash_type hash_code ) 258 inline void construct( entry_type* entry, const value_type& value, hash_type hash_code ) const 259 259 { 260 260 copy_construct_object( &(entry->value), value ); 261 entry .hash_code = hash_code;261 entry->hash_code = hash_code; 262 262 } 263 263 }; -
trunk/nv/stl/container/initialize_policy.hh
r395 r401 58 58 inline static ForwardIterator copy( InputIterator first, InputIterator last, ForwardIterator out ) 59 59 { 60 return detail::uninitialized_copy ( first, last, out, true_type);60 return detail::uninitialized_copy_impl( first, last, out, true_type() ); 61 61 } 62 62 template < typename ForwardIterator > -
trunk/nv/stl/container/sized_container_handler.hh
r395 r401 78 78 inline void assign( InputIterator first, InputIterator last ) 79 79 { 80 // TODO: distance can't be called on destructive iterators - check 81 // and use pushback if needed? 80 82 size_type d = distance( first, last ); 81 if ( d != Storage::size() && Storage::try_resize( sz, false ) )83 if ( d != Storage::size() && Storage::try_resize( d, false ) ) 82 84 InitializePolicy::copy( first, last, Storage::data() ); 83 85 } -
trunk/nv/stl/functional/hash.hh
r400 r401 137 137 constexpr H hash_value( const T& value ) 138 138 { 139 return hash<T, H>::get( h);139 return hash<T, H>::get( value ); 140 140 } 141 141 … … 183 183 184 184 constexpr hashed_element( const T& v, H h ) : value(v), hash( h ) {} 185 constexpr hashed_element( T&& v, H h ) : value( std::forward<T>(v) ), hash( h ) {}185 constexpr hashed_element( T&& v, H h ) : value( nv::forward<T>(v) ), hash( h ) {} 186 186 187 187 hashed_element( const hashed_element& ) = default; -
trunk/nv/stl/iterator.hh
r395 r401 15 15 16 16 #include <nv/common.hh> 17 #include <nv/stl/type_traits/common.hh> 17 18 18 19 namespace nv -
trunk/nv/stl/memory.hh
r400 r401 19 19 #include <nv/stl/type_traits/properties.hh> 20 20 #include <nv/stl/type_traits/alignment.hh> 21 #include <nv/stl/algorithm/fill.hh> 22 #include <nv/stl/algorithm/copy.hh> 21 23 #include <nv/stl/utility.hh> 22 24 #include <nv/stl/iterator.hh> … … 277 279 inline ForwardIterator uninitialized_copy_impl( InputIterator first, InputIterator last, ForwardIterator out, true_type ) 278 280 { 279 return ForwardIterator( nvmemmove( out, first, (size_t)( (uintptr_t)last - (uintptr_t)first )) );281 return ForwardIterator( raw_alias_copy( first, last, out ) ); 280 282 } 281 283 … … 290 292 ::new ( static_cast<void*>( addressof( *dest ) ) ) value_type( *src ); 291 293 } 292 return it;294 return dest; 293 295 } 294 296 … … 296 298 inline ForwardIterator uninitialized_copy_n_impl( InputIterator first, size_t count, ForwardIterator out, true_type ) 297 299 { 298 typedef typename iterator_traits<ForwardIterator>::value_type value_type; 299 return ForwardIterator( nvmemmove( out, first, count * sizeof( value_type ) ) ); 300 return ForwardIterator( raw_alias_copy_n( out, first, count ) ); 300 301 } 301 302 -
trunk/nv/stl/string.hh
r400 r401 100 100 typedef string_base< detail::add_iterators< Storage > > this_type; 101 101 public: 102 typedef Storage storage_type; 103 typedef typename base_type::value_type value_type; 104 typedef typename base_type::pointer pointer; 105 typedef typename base_type::const_pointer const_pointer; 106 typedef typename base_type::reference reference; 107 typedef typename base_type::const_reference const_reference; 108 typedef typename base_type::iterator iterator; 109 typedef typename base_type::const_iterator const_iterator; 110 typedef typename base_type::size_type size_type; 111 typedef typename base_type::difference_type difference_type; 102 typedef Storage storage_type; 103 typedef typename base_type::value_type value_type; 104 typedef typename base_type::pointer pointer; 105 typedef typename base_type::const_pointer const_pointer; 106 typedef typename base_type::reference reference; 107 typedef typename base_type::const_reference const_reference; 108 typedef typename base_type::iterator iterator; 109 typedef typename base_type::const_iterator const_iterator; 110 typedef typename base_type::reverse_iterator reverse_iterator; 111 typedef typename base_type::const_reverse_iterator const_reverse_iterator; 112 typedef typename base_type::size_type size_type; 113 typedef typename base_type::difference_type difference_type; 112 114 113 115 static constexpr size_type npos = size_type( -1 ); … … 116 118 inline std::string to_string() const 117 119 { 118 return std::string( data(),size() );120 return std::string( this->data(), this->size() ); 119 121 } 120 122 121 inline size_type length() const { return size(); }123 inline size_type length() const { return this->size(); } 122 124 123 125 // access 124 inline value_type operator[]( size_type i ) const { return data()[i]; }126 inline value_type operator[]( size_type i ) const { return this->data()[i]; } 125 127 inline value_type at( size_type i ) const 126 128 { 127 129 // if ( i >= m_data ) NV_THROW( out_of_range( "string_ref::at" ) ); 128 return data()[i];129 } 130 131 inline value_type front() const { return data()[0]; }132 inline value_type back() const { return data()[size() - 1]; }130 return this->data()[i]; 131 } 132 133 inline value_type front() const { return this->data()[0]; } 134 inline value_type back() const { return this->data()[this->size() - 1]; } 133 135 134 136 // string operations … … 155 157 156 158 template < typename H = size_type > 157 inline H hash() const159 inline H get_hash() const 158 160 { 159 161 return hash_string< size_type >( this->data(), this->size() ); … … 175 177 static H get( const T& value ) 176 178 { 177 return value. hash< H >();179 return value.template get_hash< H >(); 178 180 } 179 181 inline H operator()( const T& value ) const { return get( value ); } … … 277 279 278 280 template < typename Storage > 279 inline auto string_base< Storage >::find( value_type c, size_type pos = 0) const -> size_type281 inline auto string_base< Storage >::find( value_type c, size_type pos /*= 0*/ ) const -> size_type 280 282 { 281 283 if ( pos >= this->size() ) return npos; … … 284 286 } 285 287 template < typename Storage > 286 inline auto string_base< Storage >::find( const string_view& s, size_type pos = 0) const -> size_type288 inline auto string_base< Storage >::find( const string_view& s, size_type pos /*= 0*/ ) const -> size_type 287 289 { 288 290 if ( pos >= this->size() ) return npos; … … 292 294 293 295 template < typename Storage > 294 inline auto string_base< Storage >::rfind( value_type c, size_type pos = 0) const -> size_type296 inline auto string_base< Storage >::rfind( value_type c, size_type pos /*= 0*/ ) const -> size_type 295 297 { 296 298 if ( pos >= this->size() ) return npos; … … 299 301 } 300 302 template < typename Storage > 301 inline auto string_base< Storage >::rfind( const string_view& s, size_type pos = 0) const -> size_type303 inline auto string_base< Storage >::rfind( const string_view& s, size_type pos /*= 0*/ ) const -> size_type 302 304 { 303 305 if ( pos >= this->size() ) return npos; -
trunk/nv/stl/type_traits/alignment.hh
r395 r401 15 15 16 16 #include <nv/stl/type_traits/common.hh> 17 #include <nv/stl/type_traits/properties.hh> 17 18 18 19 namespace nv … … 45 46 #endif 46 47 47 #if NV_COMPILER == NV_CLANG48 template< typename T, size_t Size, size_t Align >49 struct aligned_array50 {51 typedef T alignas( Align ) type[Size];52 };53 #elif NV_COMPILER == NV_GNUC54 template< typename T, size_t Size, size_t Align >55 struct aligned_array56 {57 typedef T __attribute__( ( aligned( Align ) ) ) type[Size];58 };59 #else60 // TODO: remove this shit after moving to MSVC 201561 template< typename T, size_t Size, size_t Align >62 struct aligned_array;63 64 // According to LLVM ( https://llvm.org/svn/llvm-project/llvm/trunk/include/llvm/Support/AlignOf.h )65 // MSVC has problems with align below 16...66 #define NV_ALIGNED_ARRAY(N) \67 template< typename T, size_t Size > \68 struct aligned_array< T, Size, N > \69 { \70 typedef __declspec( align(N) ) T type[Size]; \71 };72 73 NV_ALIGNED_ARRAY( 1 )74 NV_ALIGNED_ARRAY( 2 )75 NV_ALIGNED_ARRAY( 4 )76 NV_ALIGNED_ARRAY( 8 )77 NV_ALIGNED_ARRAY( 16 )78 NV_ALIGNED_ARRAY( 32 )79 NV_ALIGNED_ARRAY( 64 )80 NV_ALIGNED_ARRAY( 128 )81 82 #undef NV_ALIGNED_ARRAY83 #endif84 85 template< typename T, size_t Size, size_t Align >86 using aligned_array_t = typename aligned_array< T, Size, Align >::type;87 88 48 template< size_t Size, size_t Align = alignof( max_align_t ) > 89 49 struct aligned_storage … … 91 51 struct type 92 52 { 93 typename aligned_array< unsigned char, Size, Align >::type data;53 alignas( Align ) unsigned char data[ Size ]; 94 54 }; 95 55 }; … … 124 84 static constexpr size_t max_length = detail::size_max < Size, sizeof( Types )... >::value; 125 85 static constexpr size_t alignment_value = detail::size_max < alignment_of< Types >::value... >::value; 126 struct type 127 { 128 typename aligned_array< unsigned char, max_length, alignment_value >::type data; 129 }; 86 using type = aligned_storage_t< max_length, alignment_value >; 130 87 }; 131 88 -
trunk/nv/stl/type_traits/common.hh
r395 r401 96 96 template< typename T > struct add_reference 97 97 { 98 typedef typenameconditional< is_reference<T>::value, T, T&& > type;98 typedef conditional< is_reference<T>::value, T, T&& > type; 99 99 }; 100 100 template<> struct add_reference < void > { typedef void type; }; -
trunk/nv/stl/type_traits/transforms.hh
r395 r401 259 259 #else 260 260 template < typename F, typename... Args > 261 struct result_of < F( Args... ) > { typedef decltype( invoke( declval< T>(), declval<Args>()... ) ) type; };261 struct result_of < F( Args... ) > { typedef decltype( invoke( declval<F>(), declval<Args>()... ) ) type; }; 262 262 #endif 263 263 -
trunk/nv/stl/unordered_map.hh
r395 r401 45 45 typedef hash_table< hash_table_entry_stl_map< Key, T, size_t, KeyEqual, Hash > > base_type; 46 46 typedef unordered_map< Key, T, Hash, KeyEqual > this_type; 47 typedef typename base_type::value_type value_type; 48 typedef typename base_type::pointer pointer; 49 typedef typename base_type::const_pointer const_pointer; 50 typedef typename base_type::reference reference; 51 typedef typename base_type::const_reference const_reference; 52 typedef typename base_type::iterator iterator; 53 typedef typename base_type::const_iterator const_iterator; 47 54 typedef typename base_type::size_type size_type; 55 typedef typename base_type::difference_type difference_type; 48 56 typedef typename base_type::key_type key_type; 49 57 typedef typename base_type::mapped_type mapped_type; 50 typedef typename base_type::value_type value_type;51 58 typedef typename base_type::node_type node_type; 52 59 typedef typename base_type::insert_return_type insert_return_type; 53 typedef typename base_type::iterator iterator;54 60 typedef Hash hasher; 55 61 typedef KeyEqual key_equal; -
trunk/src/core/time.cc
r395 r401 17 17 #pragma intrinsic(__rdtsc) 18 18 #else 19 #if NV_ COMPILER == NV_GNUC && NV_PLATFORM == NV_WINDOWS19 #if NV_PLATFORM == NV_WINDOWS 20 20 // mingw doesn't have usleep nor nanosleep... 21 21 #include <windows.h> … … 71 71 Sleep( ms ); 72 72 #else 73 #if NV_ COMPILER == NV_GNUC && NV_PLATFORM == NV_WINDOWS73 #if NV_PLATFORM == NV_WINDOWS 74 74 Sleep( ms ); 75 75 #else -
trunk/src/formats/md5_loader.cc
r399 r401 10 10 #include "nv/stl/vector.hh" 11 11 #include "nv/io/std_stream.hh" 12 13 #include <stdio.h> // sscanf 14 #include <stdlib.h> // atof 12 15 13 16 using namespace nv; -
trunk/src/gui/gui_environment.cc
r395 r401 9 9 #include "nv/gui/gui_renderer.hh" 10 10 11 #include <algorithm> // std::find on std::list 11 12 12 13 /*
Note: See TracChangeset
for help on using the changeset viewer.