2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_TYPEINDEX
11 #define _LIBCPP_TYPEINDEX
23 type_index(const type_info& rhs) noexcept;
25 bool operator==(const type_index& rhs) const 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;
32 size_t hash_code() const noexcept;
33 const char* name() const noexcept;
37 struct hash<type_index>
38 : public unary_function<type_index, size_t>
40 size_t operator()(type_index index) const noexcept;
48 #include <__functional/unary_function.h>
49 #include <__functional_base>
54 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
55 #pragma GCC system_header
58 _LIBCPP_BEGIN_NAMESPACE_STD
60 class _LIBCPP_TEMPLATE_VIS type_index
62 const type_info* __t_;
64 _LIBCPP_INLINE_VISIBILITY
65 type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}
67 _LIBCPP_INLINE_VISIBILITY
68 bool operator==(const type_index& __y) const _NOEXCEPT
69 {return *__t_ == *__y.__t_;}
70 _LIBCPP_INLINE_VISIBILITY
71 bool operator!=(const type_index& __y) const _NOEXCEPT
72 {return *__t_ != *__y.__t_;}
73 _LIBCPP_INLINE_VISIBILITY
74 bool operator< (const type_index& __y) const _NOEXCEPT
75 {return __t_->before(*__y.__t_);}
76 _LIBCPP_INLINE_VISIBILITY
77 bool operator<=(const type_index& __y) const _NOEXCEPT
78 {return !__y.__t_->before(*__t_);}
79 _LIBCPP_INLINE_VISIBILITY
80 bool operator> (const type_index& __y) const _NOEXCEPT
81 {return __y.__t_->before(*__t_);}
82 _LIBCPP_INLINE_VISIBILITY
83 bool operator>=(const type_index& __y) const _NOEXCEPT
84 {return !__t_->before(*__y.__t_);}
86 _LIBCPP_INLINE_VISIBILITY
87 size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
88 _LIBCPP_INLINE_VISIBILITY
89 const char* name() const _NOEXCEPT {return __t_->name();}
92 template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
95 struct _LIBCPP_TEMPLATE_VIS hash<type_index>
96 : public unary_function<type_index, size_t>
98 _LIBCPP_INLINE_VISIBILITY
99 size_t operator()(type_index __index) const _NOEXCEPT
100 {return __index.hash_code();}
103 _LIBCPP_END_NAMESPACE_STD
105 #endif // _LIBCPP_TYPEINDEX