Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===-------------------------- typeinfo ----------------------------------===// |
| 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_TYPEINFO |
| 12 | #define __LIBCPP_TYPEINFO |
| 13 | |
| 14 | /* |
| 15 | |
| 16 | typeinfo synopsis |
| 17 | |
| 18 | namespace std { |
| 19 | |
| 20 | class type_info |
| 21 | { |
| 22 | public: |
| 23 | virtual ~type_info(); |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 24 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 25 | bool operator==(const type_info& rhs) const noexcept; |
| 26 | bool operator!=(const type_info& rhs) const noexcept; |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 27 | |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 28 | bool before(const type_info& rhs) const noexcept; |
| 29 | size_t hash_code() const noexcept; |
| 30 | const char* name() const noexcept; |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 31 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 32 | type_info(const type_info& rhs) = delete; |
| 33 | type_info& operator=(const type_info& rhs) = delete; |
| 34 | }; |
| 35 | |
| 36 | class bad_cast |
| 37 | : public exception |
| 38 | { |
| 39 | public: |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 40 | bad_cast() noexcept; |
| 41 | bad_cast(const bad_cast&) noexcept; |
| 42 | bad_cast& operator=(const bad_cast&) noexcept; |
| 43 | virtual const char* what() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 44 | }; |
| 45 | |
| 46 | class bad_typeid |
| 47 | : public exception |
| 48 | { |
| 49 | public: |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 50 | bad_typeid() noexcept; |
| 51 | bad_typeid(const bad_typeid&) noexcept; |
| 52 | bad_typeid& operator=(const bad_typeid&) noexcept; |
| 53 | virtual const char* what() const noexcept; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | } // std |
| 57 | |
| 58 | */ |
| 59 | |
| 60 | #include <__config> |
| 61 | #include <exception> |
| 62 | #include <cstddef> |
| 63 | |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 64 | #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 65 | #pragma GCC system_header |
Howard Hinnant | 08e1747 | 2011-10-17 20:05:10 +0000 | [diff] [blame] | 66 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 67 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 68 | namespace std // purposefully not using versioning namespace |
| 69 | { |
| 70 | |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 71 | class _LIBCPP_EXCEPTION_ABI type_info |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 72 | { |
| 73 | type_info& operator=(const type_info&); |
| 74 | type_info(const type_info&); |
| 75 | protected: |
| 76 | const char* __type_name; |
| 77 | |
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 | explicit type_info(const char* __n) |
| 80 | : __type_name(__n) {} |
| 81 | |
| 82 | public: |
| 83 | virtual ~type_info(); |
| 84 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 85 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 86 | const char* name() const _NOEXCEPT {return __type_name;} |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 87 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 88 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 89 | bool before(const type_info& __arg) const _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 90 | {return __type_name < __arg.__type_name;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 91 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 92 | size_t hash_code() const _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 93 | {return *reinterpret_cast<const size_t*>(&__type_name);} |
| 94 | |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 95 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 96 | bool operator==(const type_info& __arg) const _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 97 | {return __type_name == __arg.__type_name;} |
Howard Hinnant | ee6ccd0 | 2010-09-23 18:58:28 +0000 | [diff] [blame] | 98 | _LIBCPP_INLINE_VISIBILITY |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 99 | bool operator!=(const type_info& __arg) const _NOEXCEPT |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 100 | {return !operator==(__arg);} |
| 101 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 102 | }; |
| 103 | |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 104 | class _LIBCPP_EXCEPTION_ABI bad_cast |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 105 | : public exception |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 106 | { |
| 107 | public: |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 108 | bad_cast() _NOEXCEPT; |
| 109 | virtual ~bad_cast() _NOEXCEPT; |
| 110 | virtual const char* what() const _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
Nick Kledzik | 804b6e7 | 2010-05-14 20:19:37 +0000 | [diff] [blame] | 113 | class _LIBCPP_EXCEPTION_ABI bad_typeid |
Howard Hinnant | 324bb03 | 2010-08-22 00:02:43 +0000 | [diff] [blame] | 114 | : public exception |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 115 | { |
| 116 | public: |
Howard Hinnant | ed56921 | 2011-05-26 18:23:59 +0000 | [diff] [blame] | 117 | bad_typeid() _NOEXCEPT; |
| 118 | virtual ~bad_typeid() _NOEXCEPT; |
| 119 | virtual const char* what() const _NOEXCEPT; |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 120 | }; |
| 121 | |
| 122 | } // std |
| 123 | |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 124 | #endif // __LIBCPP_TYPEINFO |