summaryrefslogtreecommitdiffstats
path: root/libcxx/include/typeinfo
blob: 8762de7a78c7b7be32390ee704affed6149f538e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// -*- C++ -*-
//===-------------------------- typeinfo ----------------------------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef __LIBCPP_TYPEINFO
#define __LIBCPP_TYPEINFO

/*

    typeinfo synopsis

namespace std {

class type_info
{
public:
    virtual ~type_info();
    
    bool operator==(const type_info& rhs) const;
    bool operator!=(const type_info& rhs) const;
    
    bool before(const type_info& rhs) const;
    size_t hash_code() const throw();
    const char* name() const;
    
    type_info(const type_info& rhs) = delete;
    type_info& operator=(const type_info& rhs) = delete;
};

class bad_cast
    : public exception
{
public:
    bad_cast() throw();
    bad_cast(const bad_cast&) throw();
    bad_cast& operator=(const bad_cast&) throw();
    virtual const char* what() const throw();
};

class bad_typeid
    : public exception
{
public:
    bad_typeid() throw();
    bad_typeid(const bad_typeid&) throw();
    bad_typeid& operator=(const bad_typeid&) throw();
    virtual const char* what() const throw();
};

}  // std

*/

#include <__config>
#include <exception>
#include <cstddef>

#pragma GCC system_header


namespace std  // purposefully not using versioning namespace
{

class _LIBCPP_EXCEPTION_ABI type_info 
{
    type_info& operator=(const type_info&);
    type_info(const type_info&);
protected:
    const char* __type_name;

    explicit type_info(const char* __n)
        : __type_name(__n) {}

public:
    virtual ~type_info();

    const char* name() const {return __type_name;}

    bool before(const type_info& __arg) const
        {return __type_name < __arg.__type_name;}
    size_t hash_code() const throw()
        {return *reinterpret_cast<const size_t*>(&__type_name);}

    bool operator==(const type_info& __arg) const
        {return __type_name == __arg.__type_name;}
    bool operator!=(const type_info& __arg) const
        {return !operator==(__arg);}

};

class _LIBCPP_EXCEPTION_ABI bad_cast
    : public exception 
{
public:
    bad_cast() throw();
    virtual ~bad_cast() throw();
    virtual const char* what() const throw();
};

class _LIBCPP_EXCEPTION_ABI bad_typeid
    : public exception 
{
public:
    bad_typeid() throw();
    virtual ~bad_typeid() throw();
    virtual const char* what() const throw();
};


}  // std



#endif  // __LIBCPP_TYPEINFO
OpenPOWER on IntegriCloud