Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- typeindex ---------------------------------===// |
| 3 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 4 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 5 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | #ifndef _LIBCPP_TYPEINDEX |
| 12 | #define _LIBCPP_TYPEINDEX |
| 13 | |
| 14 | /* |
| 15 | |
| 16 | typeindex synopsis |
| 17 | |
| 18 | namespace std |
| 19 | { |
| 20 | |
| 21 | class type_index |
| 22 | { |
| 23 | public: |
| 24 | type_index(const type_info& rhs); |
| 25 | |
| 26 | bool operator==(const type_index& rhs) const; |
| 27 | bool operator!=(const type_index& rhs) const; |
| 28 | bool operator< (const type_index& rhs) const; |
| 29 | bool operator<=(const type_index& rhs) const; |
| 30 | bool operator> (const type_index& rhs) const; |
| 31 | bool operator>=(const type_index& rhs) const; |
| 32 | |
| 33 | size_t hash_code() const; |
| 34 | const char* name() const; |
| 35 | }; |
| 36 | |
| 37 | template <> |
| 38 | struct hash<type_index> |
| 39 | : public unary_function<type_index, size_t> |
| 40 | { |
| 41 | size_t operator()(type_index index) const; |
| 42 | }; |
| 43 | |
| 44 | } // std |
| 45 | |
| 46 | */ |
| 47 | |
| 48 | #include <__config> |
| 49 | #include <typeinfo> |
| 50 | #include <__functional_base> |
| 51 | |
| 52 | #pragma GCC system_header |
| 53 | |
| 54 | _LIBCPP_BEGIN_NAMESPACE_STD |
| 55 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 56 | class _LIBCPP_VISIBLE type_index |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 57 | { |
| 58 | const type_info* __t_; |
| 59 | public: |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 60 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 61 | type_index(const type_info& __y) : __t_(&__y) {} |
| 62 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 63 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 64 | bool operator==(const type_index& __y) const {return *__t_ == *__y.__t_;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 65 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 66 | bool operator!=(const type_index& __y) const {return *__t_ != *__y.__t_;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 67 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 68 | bool operator< (const type_index& __y) const {return __t_->before(*__y.__t_);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 69 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 70 | bool operator<=(const type_index& __y) const {return !__y.__t_->before(*__t_);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 71 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 72 | bool operator> (const type_index& __y) const {return __y.__t_->before(*__t_);} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 73 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 74 | bool operator>=(const type_index& __y) const {return !__t_->before(*__y.__t_);} |
| 75 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 76 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 77 | size_t hash_code() const {return __t_->hash_code();} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 78 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 79 | const char* name() const {return __t_->name();} |
| 80 | }; |
| 81 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 82 | template <class _Tp> struct _LIBCPP_VISIBLE hash; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 83 | |
| 84 | template <> |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 85 | struct _LIBCPP_VISIBLE hash<type_index> |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 86 | : public unary_function<type_index, size_t> |
| 87 | { |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 88 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 89 | size_t operator()(type_index __index) const {return __index.hash_code();} |
| 90 | }; |
| 91 | |
| 92 | _LIBCPP_END_NAMESPACE_STD |
| 93 | |
| 94 | #endif // _LIBCPP_TYPEINDEX |