blob: 6ffee0f8a3c614ebd4a8e8c5afdf54f80f2d9d86 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001// -*- C++ -*-
2//===-------------------------- typeinfo ----------------------------------===//
3//
Howard Hinnantf5256e12010-05-11 21:36:01 +00004// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00005//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00006// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00008//
9//===----------------------------------------------------------------------===//
10
11#ifndef __LIBCPP_TYPEINFO
12#define __LIBCPP_TYPEINFO
13
14/*
15
16 typeinfo synopsis
17
18namespace std {
19
20class type_info
21{
22public:
23 virtual ~type_info();
Howard Hinnant324bb032010-08-22 00:02:43 +000024
Howard Hinnanted569212011-05-26 18:23:59 +000025 bool operator==(const type_info& rhs) const noexcept;
26 bool operator!=(const type_info& rhs) const noexcept;
Howard Hinnant324bb032010-08-22 00:02:43 +000027
Howard Hinnanted569212011-05-26 18:23:59 +000028 bool before(const type_info& rhs) const noexcept;
29 size_t hash_code() const noexcept;
30 const char* name() const noexcept;
Howard Hinnant324bb032010-08-22 00:02:43 +000031
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000032 type_info(const type_info& rhs) = delete;
33 type_info& operator=(const type_info& rhs) = delete;
34};
35
36class bad_cast
37 : public exception
38{
39public:
Howard Hinnanted569212011-05-26 18:23:59 +000040 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 Hinnantbc8d3f92010-05-11 19:42:16 +000044};
45
46class bad_typeid
47 : public exception
48{
49public:
Howard Hinnanted569212011-05-26 18:23:59 +000050 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 Hinnantbc8d3f92010-05-11 19:42:16 +000054};
55
56} // std
57
58*/
59
60#include <__config>
61#include <exception>
62#include <cstddef>
63
Howard Hinnant08e17472011-10-17 20:05:10 +000064#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000065#pragma GCC system_header
Howard Hinnant08e17472011-10-17 20:05:10 +000066#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000067
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000068namespace std // purposefully not using versioning namespace
69{
70
Howard Hinnant324bb032010-08-22 00:02:43 +000071class _LIBCPP_EXCEPTION_ABI type_info
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000072{
73 type_info& operator=(const type_info&);
74 type_info(const type_info&);
75protected:
76 const char* __type_name;
77
Howard Hinnantee6ccd02010-09-23 18:58:28 +000078 _LIBCPP_INLINE_VISIBILITY
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000079 explicit type_info(const char* __n)
80 : __type_name(__n) {}
81
82public:
83 virtual ~type_info();
84
Howard Hinnantee6ccd02010-09-23 18:58:28 +000085 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanted569212011-05-26 18:23:59 +000086 const char* name() const _NOEXCEPT {return __type_name;}
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000087
Howard Hinnantee6ccd02010-09-23 18:58:28 +000088 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanted569212011-05-26 18:23:59 +000089 bool before(const type_info& __arg) const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000090 {return __type_name < __arg.__type_name;}
Howard Hinnantee6ccd02010-09-23 18:58:28 +000091 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanted569212011-05-26 18:23:59 +000092 size_t hash_code() const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000093 {return *reinterpret_cast<const size_t*>(&__type_name);}
94
Howard Hinnantee6ccd02010-09-23 18:58:28 +000095 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanted569212011-05-26 18:23:59 +000096 bool operator==(const type_info& __arg) const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000097 {return __type_name == __arg.__type_name;}
Howard Hinnantee6ccd02010-09-23 18:58:28 +000098 _LIBCPP_INLINE_VISIBILITY
Howard Hinnanted569212011-05-26 18:23:59 +000099 bool operator!=(const type_info& __arg) const _NOEXCEPT
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000100 {return !operator==(__arg);}
101
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000102};
103
Nick Kledzik804b6e72010-05-14 20:19:37 +0000104class _LIBCPP_EXCEPTION_ABI bad_cast
Howard Hinnant324bb032010-08-22 00:02:43 +0000105 : public exception
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000106{
107public:
Howard Hinnanted569212011-05-26 18:23:59 +0000108 bad_cast() _NOEXCEPT;
109 virtual ~bad_cast() _NOEXCEPT;
110 virtual const char* what() const _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000111};
112
Nick Kledzik804b6e72010-05-14 20:19:37 +0000113class _LIBCPP_EXCEPTION_ABI bad_typeid
Howard Hinnant324bb032010-08-22 00:02:43 +0000114 : public exception
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000115{
116public:
Howard Hinnanted569212011-05-26 18:23:59 +0000117 bad_typeid() _NOEXCEPT;
118 virtual ~bad_typeid() _NOEXCEPT;
119 virtual const char* what() const _NOEXCEPT;
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000120};
121
122} // std
123
Howard Hinnantbc8d3f92010-05-11 19:42:16 +0000124#endif // __LIBCPP_TYPEINFO