1// -*- C++ -*-
2//===-------------------------- typeindex ---------------------------------===//
3//
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
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef _LIBCPP_TYPEINDEX
11#define _LIBCPP_TYPEINDEX
12
13/*
14
15    typeindex synopsis
16
17namespace std
18{
19
20class type_index
21{
22public:
23    type_index(const type_info& rhs) noexcept;
24
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;
31
32    size_t hash_code() const noexcept;
33    const char* name() const noexcept;
34};
35
36template <>
37struct hash<type_index>
38    : public unary_function<type_index, size_t>
39{
40    size_t operator()(type_index index) const noexcept;
41};
42
43}  // std
44
45*/
46
47#include <__config>
48#include <__functional/unary_function.h>
49#include <__functional_base>
50#include <compare>
51#include <typeinfo>
52
53#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
54#pragma GCC system_header
55#endif
56
57_LIBCPP_BEGIN_NAMESPACE_STD
58
59class _LIBCPP_TEMPLATE_VIS type_index
60{
61    const type_info* __t_;
62public:
63    _LIBCPP_INLINE_VISIBILITY
64    type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}
65
66    _LIBCPP_INLINE_VISIBILITY
67    bool operator==(const type_index& __y) const _NOEXCEPT
68        {return *__t_ == *__y.__t_;}
69    _LIBCPP_INLINE_VISIBILITY
70    bool operator!=(const type_index& __y) const _NOEXCEPT
71        {return *__t_ != *__y.__t_;}
72    _LIBCPP_INLINE_VISIBILITY
73    bool operator< (const type_index& __y) const _NOEXCEPT
74        {return  __t_->before(*__y.__t_);}
75    _LIBCPP_INLINE_VISIBILITY
76    bool operator<=(const type_index& __y) const _NOEXCEPT
77        {return !__y.__t_->before(*__t_);}
78    _LIBCPP_INLINE_VISIBILITY
79    bool operator> (const type_index& __y) const _NOEXCEPT
80        {return  __y.__t_->before(*__t_);}
81    _LIBCPP_INLINE_VISIBILITY
82    bool operator>=(const type_index& __y) const _NOEXCEPT
83        {return !__t_->before(*__y.__t_);}
84
85    _LIBCPP_INLINE_VISIBILITY
86    size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
87    _LIBCPP_INLINE_VISIBILITY
88    const char* name() const _NOEXCEPT {return __t_->name();}
89};
90
91template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash;
92
93template <>
94struct _LIBCPP_TEMPLATE_VIS hash<type_index>
95    : public unary_function<type_index, size_t>
96{
97    _LIBCPP_INLINE_VISIBILITY
98    size_t operator()(type_index __index) const _NOEXCEPT
99        {return __index.hash_code();}
100};
101
102_LIBCPP_END_NAMESPACE_STD
103
104#endif // _LIBCPP_TYPEINDEX
105