1// -*- C++ -*-
2//===-------------------------- typeindex ---------------------------------===//
3//
4//                     The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef _LIBCPP_TYPEINDEX
12#define _LIBCPP_TYPEINDEX
13
14/*
15
16    typeindex synopsis
17
18namespace std
19{
20
21class type_index
22{
23public:
24    type_index(const type_info& rhs) noexcept;
25
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;
32
33    size_t hash_code() const noexcept;
34    const char* name() const noexcept;
35};
36
37template <>
38struct hash<type_index>
39    : public unary_function<type_index, size_t>
40{
41    size_t operator()(type_index index) const noexcept;
42};
43
44}  // std
45
46*/
47
48#include <__config>
49#include <typeinfo>
50#include <__functional_base>
51
52#pragma GCC system_header
53
54_LIBCPP_BEGIN_NAMESPACE_STD
55
56class _LIBCPP_VISIBLE type_index
57{
58    const type_info* __t_;
59public:
60    _LIBCPP_INLINE_VISIBILITY
61    type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}
62
63    _LIBCPP_INLINE_VISIBILITY
64    bool operator==(const type_index& __y) const _NOEXCEPT
65        {return *__t_ == *__y.__t_;}
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_->before(*__y.__t_);}
72    _LIBCPP_INLINE_VISIBILITY
73    bool operator<=(const type_index& __y) const _NOEXCEPT
74        {return !__y.__t_->before(*__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 !__t_->before(*__y.__t_);}
81
82    _LIBCPP_INLINE_VISIBILITY
83    size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
84    _LIBCPP_INLINE_VISIBILITY
85    const char* name() const _NOEXCEPT {return __t_->name();}
86};
87
88template <class _Tp> struct _LIBCPP_VISIBLE hash;
89
90template <>
91struct _LIBCPP_VISIBLE hash<type_index>
92    : public unary_function<type_index, size_t>
93{
94    _LIBCPP_INLINE_VISIBILITY
95    size_t operator()(type_index __index) const _NOEXCEPT
96        {return __index.hash_code();}
97};
98
99_LIBCPP_END_NAMESPACE_STD
100
101#endif  // _LIBCPP_TYPEINDEX
102