Photon microGUI widgets library 0.6.0
typeindex.hpp
1#ifndef _STDEX_TYPEINDEX_H
2#define _STDEX_TYPEINDEX_H
3
4#if _MSC_VER > 1000
5#pragma once
6#endif // _MSC_VER > 1000
7
8// stdex includes
9/*none*/
10
11// POSIX includes
12/*none*/
13
14// std includes
15#include <typeinfo> // std::typeinfo
16#include <cstddef> // std::size_t
17
18#ifdef _STDEX_NATIVE_CPP11_SUPPORT
19
20#define _STDEX_DELETED_FUNCTION =delete
21#define _STDEX_NOEXCEPT_FUNCTION noexcept
22
23#else
24
25#define _STDEX_DELETED_FUNCTION
26#define _STDEX_NOEXCEPT_FUNCTION throw()
27
28#endif
29
30namespace stdex
31{
32 using std::type_info;
33
34 struct type_index
35 {
36 type_index(const stdex::type_info& _tinfo) _STDEX_NOEXCEPT_FUNCTION
37 : _type_info_obj(&_tinfo)
38 { }
39
40 bool
41 operator==(const type_index& _other) const _STDEX_NOEXCEPT_FUNCTION
42 { return *_type_info_obj == *_other._type_info_obj; }
43
44 bool
45 operator!=(const type_index& _other) const _STDEX_NOEXCEPT_FUNCTION
46 { return *_type_info_obj != *_other._type_info_obj; }
47
48 bool
49 operator<(const type_index& _other) const _STDEX_NOEXCEPT_FUNCTION
50 { return !!_type_info_obj->before(*_other._type_info_obj); }
51
52 bool
53 operator<=(const type_index& _other) const _STDEX_NOEXCEPT_FUNCTION
54 { return !_other._type_info_obj->before(*_type_info_obj); }
55
56 bool
57 operator>(const type_index& _other) const _STDEX_NOEXCEPT_FUNCTION
58 { return !!_other._type_info_obj->before(*_type_info_obj); }
59
60 bool
61 operator>=(const type_index& _other) const _STDEX_NOEXCEPT_FUNCTION
62 { return !_type_info_obj->before(*_other._type_info_obj); }
63
64 const char*
65 name() const _STDEX_NOEXCEPT_FUNCTION
66 { return _type_info_obj->name(); }
67
68 /*std::size_t
69 hash_code() const _STDEX_NOEXCEPT_FUNCTION
70 { return _type_info_obj->hash_code(); }*/
71
72 private:
73 const stdex::type_info* _type_info_obj;
74 };
75
76 //template<class _Tp> struct hash;
77
78 // stdex::hash specialization for type_index.
79 /*template<>
80 struct hash<stdex::type_index>
81 {
82 typedef std::size_t result_type;
83 typedef stdex::type_index argument_type;
84
85 std::size_t
86 operator()(const type_index& _tinfo) const _STDEX_NOEXCEPT_FUNCTION
87 { return _tinfo.hash_code(); }
88 };*/
89
90} // namespace stdex
91
92#undef _STDEX_DELETED_FUNCTION
93#undef _STDEX_NOEXCEPT_FUNCTION
94
95#endif // _STDEX_TYPEINDEX_H