2 //===-------------------------- typeindex ---------------------------------===//
4 // The LLVM Compiler Infrastructure
6 // This file is dual licensed under the MIT and the University of Illinois Open
7 // Source Licenses. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 #ifndef _LIBCPP_TYPEINDEX
12 #define _LIBCPP_TYPEINDEX
24 type_index(const type_info& rhs) noexcept;
26 bool operator==(const type_index& rhs) const noexcept;
27 bool operator!=(const type_index& rhs) const noexcept;
28 bool operator< (const type_index& rhs) const noexcept;
29 bool operator<=(const type_index& rhs) const noexcept;
30 bool operator> (const type_index& rhs) const noexcept;
31 bool operator>=(const type_index& rhs) const noexcept;
33 size_t hash_code() const noexcept;
34 const char* name() const noexcept;
38 struct hash<type_index>
39 : public unary_function<type_index, size_t>
41 size_t operator()(type_index index) const noexcept;
50 #include <__functional_base>
52 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
53 #pragma GCC system_header
56 _LIBCPP_BEGIN_NAMESPACE_STD
58 class _LIBCPP_TEMPLATE_VIS type_index
60 const type_info* __t_;
62 _LIBCPP_INLINE_VISIBILITY
63 type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}
65 _LIBCPP_INLINE_VISIBILITY
66 bool operator==(const type_index& __y) const _NOEXCEPT
67 {return *__t_ == *__y.__t_;}
68 _LIBCPP_INLINE_VISIBILITY
69 bool operator!=(const type_index& __y) const _NOEXCEPT
70 {return *__t_ != *__y.__t_;}
71 _LIBCPP_INLINE_VISIBILITY
72 bool operator< (const type_index& __y) const _NOEXCEPT
73 {return __t_->before(*__y.__t_);}
74 _LIBCPP_INLINE_VISIBILITY
75 bool operator<=(const type_index& __y) const _NOEXCEPT
76 {return !__y.__t_->before(*__t_);}
77 _LIBCPP_INLINE_VISIBILITY
78 bool operator> (const type_index& __y) const _NOEXCEPT
79 {return __y.__t_->before(*__t_);}
80 _LIBCPP_INLINE_VISIBILITY
81 bool operator>=(const type_index& __y) const _NOEXCEPT
82 {return !__t_->before(*__y.__t_);}
84 _LIBCPP_INLINE_VISIBILITY
85 size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
86 _LIBCPP_INLINE_VISIBILITY
87 const char* name() const _NOEXCEPT {return __t_->name();}
90 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
93 struct _LIBCPP_TEMPLATE_VIS hash<type_index>
94 : public unary_function<type_index, size_t>
96 _LIBCPP_INLINE_VISIBILITY
97 size_t operator()(type_index __index) const _NOEXCEPT
98 {return __index.hash_code();}
101 _LIBCPP_END_NAMESPACE_STD
103 #endif // _LIBCPP_TYPEINDEX