1// -*- C++ -*-
2//===-------------------------- typeinfo ----------------------------------===//
3//
4//                     The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
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();
24
25    bool operator==(const type_info& rhs) const;
26    bool operator!=(const type_info& rhs) const;
27
28    bool before(const type_info& rhs) const;
29    size_t hash_code() const throw();
30    const char* name() const;
31
32    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:
40    bad_cast() throw();
41    bad_cast(const bad_cast&) throw();
42    bad_cast& operator=(const bad_cast&) throw();
43    virtual const char* what() const throw();
44};
45
46class bad_typeid
47    : public exception
48{
49public:
50    bad_typeid() throw();
51    bad_typeid(const bad_typeid&) throw();
52    bad_typeid& operator=(const bad_typeid&) throw();
53    virtual const char* what() const throw();
54};
55
56}  // std
57
58*/
59
60#include <__config>
61#include <exception>
62#include <cstddef>
63
64#pragma GCC system_header
65
66namespace std  // purposefully not using versioning namespace
67{
68
69class _LIBCPP_EXCEPTION_ABI type_info
70{
71    type_info& operator=(const type_info&);
72    type_info(const type_info&);
73protected:
74    const char* __type_name;
75
76    _LIBCPP_INLINE_VISIBILITY
77    explicit type_info(const char* __n)
78        : __type_name(__n) {}
79
80public:
81    virtual ~type_info();
82
83    _LIBCPP_INLINE_VISIBILITY
84    const char* name() const {return __type_name;}
85
86    _LIBCPP_INLINE_VISIBILITY
87    bool before(const type_info& __arg) const
88        {return __type_name < __arg.__type_name;}
89    _LIBCPP_INLINE_VISIBILITY
90    size_t hash_code() const throw()
91        {return *reinterpret_cast<const size_t*>(&__type_name);}
92
93    _LIBCPP_INLINE_VISIBILITY
94    bool operator==(const type_info& __arg) const
95        {return __type_name == __arg.__type_name;}
96    _LIBCPP_INLINE_VISIBILITY
97    bool operator!=(const type_info& __arg) const
98        {return !operator==(__arg);}
99
100};
101
102class _LIBCPP_EXCEPTION_ABI bad_cast
103    : public exception
104{
105public:
106    bad_cast() throw();
107    virtual ~bad_cast() throw();
108    virtual const char* what() const throw();
109};
110
111class _LIBCPP_EXCEPTION_ABI bad_typeid
112    : public exception
113{
114public:
115    bad_typeid() throw();
116    virtual ~bad_typeid() throw();
117    virtual const char* what() const throw();
118};
119
120}  // std
121
122#endif  // __LIBCPP_TYPEINFO
123