Changeset 370
- Timestamp:
- 05/22/15 13:23:02 (10 years ago)
- Location:
- trunk/nv
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/nv/core/types.hh
r352 r370 7 7 8 8 #include <nv/core/common.hh> 9 #include <nv/core/math.hh> 10 #include <nv/core/cstring_store.hh> 11 #include <nv/core/type_traits.hh> 12 #include <typeinfo> 13 #include <typeindex> 14 #include <utility> 9 #include <nv/stl/math.hh> 10 #include <nv/stl/cstring_store.hh> 11 #include <nv/stl/type_traits.hh> 15 12 #include <unordered_map> 16 13 #include <vector> 17 #include <string>18 #include <cstddef>19 14 20 15 namespace nv … … 121 116 type_entry* get_type( const std::type_info& t ) 122 117 { 123 type_info_map::iterator it = m_idx_types.find( std::type_index( t ) );118 type_info_map::iterator it = m_idx_types.find( type_index( t ) ); 124 119 if ( it != m_idx_types.end() ) 125 120 { … … 140 135 private: 141 136 typedef std::vector<type_entry*> type_list; 142 typedef std::unordered_map< std::type_index, type_entry*> type_info_map;137 typedef std::unordered_map<type_index, type_entry*> type_info_map; 143 138 cstring_store m_names; 144 139 type_list m_type_list; -
trunk/nv/stl/type_traits.hh
r368 r370 18 18 #include <nv/core/common.hh> 19 19 #include <type_traits> 20 #include <typeinfo> 21 #include <string> 20 22 21 23 namespace nv … … 173 175 }; 174 176 177 class type_index 178 { 179 public: 180 inline type_index( const std::type_info& info ) : m_type_info( &info ) {} 181 inline size_t hash_code() const { return m_type_info->hash_code(); } 182 inline const char *name() const { return m_type_info->name(); } 183 184 inline bool operator==( const type_index& rhs ) const 185 { 186 return ( *m_type_info == *rhs.m_type_info ); 187 } 188 189 inline bool operator!=( const type_index& rhs ) const 190 { 191 return ( !( *this == rhs ) ); 192 } 193 194 inline bool operator<( const type_index& rhs ) const 195 { 196 return ( m_type_info->before( *rhs.m_type_info ) ); 197 } 198 199 inline bool operator>=( const type_index& rhs ) const 200 { 201 return ( !( *this < rhs ) ); 202 } 203 204 inline bool operator>( const type_index& rhs ) const 205 { 206 return ( rhs < *this ); 207 } 208 209 inline bool operator<=( const type_index& rhs ) const 210 { 211 return ( !( rhs < *this ) ); 212 } 213 214 private: 215 const std::type_info* m_type_info; 216 }; 175 217 176 218 } 177 219 220 namespace std 221 { 222 template<> 223 struct hash< nv::type_index > 224 { 225 size_t operator()( nv::type_index key ) const 226 { 227 return ( key.hash_code() ); 228 } 229 }; 230 } 231 178 232 #endif // NV_CORE_TYPE_TRAITS_HH
Note: See TracChangeset
for help on using the changeset viewer.