-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathtypeinfo_test.cc
62 lines (57 loc) · 1.69 KB
/
typeinfo_test.cc
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
#include <stdint.h>
namespace __cxxabiv1
{
struct __class_type_info;
}
using __cxxabiv1::__class_type_info;
namespace std
{
/**
* std::type_info defined with the GCC ABI. This may not be exposed in
* public headers, but is required for correctly implementing the unified
* exception model.
*/
class type_info
{
public:
virtual ~type_info();
bool operator==(const type_info &) const;
bool operator!=(const type_info &) const;
bool before(const type_info &) const;
private:
type_info(const type_info& rhs);
type_info& operator= (const type_info& rhs);
const char *__type_name;
protected:
type_info(const char *name): __type_name(name) { }
public:
const char* name() const { return __type_name; }
virtual bool __is_pointer_p() const;
virtual bool __is_function_p() const;
virtual bool __do_catch(const type_info *thrown_type,
void **thrown_object,
unsigned outer) const;
virtual bool __do_upcast(
const __class_type_info *target,
void **thrown_object) const;
};
}
class type_info2 : public std::type_info
{
public:
type_info2() : type_info("foo") {}
virtual bool __is_pointer_p() const;
virtual bool __is_function_p() const { return true; }
virtual bool __do_catch(const type_info *thrown_type,
void **thrown_object,
unsigned outer) const { return true; }
virtual bool __do_upcast(
const __class_type_info *target,
void **thrown_object) const { return true; };
};
bool type_info2::__is_pointer_p() const { return true; }
int main()
{
type_info2 s;
return s.__is_pointer_p();
}