Changeset 370 for trunk/nv/stl/type_traits.hh
- Timestamp:
- 05/22/15 13:23:02 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.