1227825Stheraven// -*- C++ -*-
2227825Stheraven//===-------------------------- typeindex ---------------------------------===//
3227825Stheraven//
4227825Stheraven//                     The LLVM Compiler Infrastructure
5227825Stheraven//
6227825Stheraven// This file is dual licensed under the MIT and the University of Illinois Open
7227825Stheraven// Source Licenses. See LICENSE.TXT for details.
8227825Stheraven//
9227825Stheraven//===----------------------------------------------------------------------===//
10227825Stheraven
11227825Stheraven#ifndef _LIBCPP_TYPEINDEX
12227825Stheraven#define _LIBCPP_TYPEINDEX
13227825Stheraven
14227825Stheraven/*
15227825Stheraven
16227825Stheraven    typeindex synopsis
17227825Stheraven
18227825Stheravennamespace std
19227825Stheraven{
20227825Stheraven
21227825Stheravenclass type_index
22227825Stheraven{
23227825Stheravenpublic:
24227825Stheraven    type_index(const type_info& rhs) noexcept;
25227825Stheraven
26227825Stheraven    bool operator==(const type_index& rhs) const noexcept;
27227825Stheraven    bool operator!=(const type_index& rhs) const noexcept;
28227825Stheraven    bool operator< (const type_index& rhs) const noexcept;
29227825Stheraven    bool operator<=(const type_index& rhs) const noexcept;
30227825Stheraven    bool operator> (const type_index& rhs) const noexcept;
31227825Stheraven    bool operator>=(const type_index& rhs) const noexcept;
32227825Stheraven
33227825Stheraven    size_t hash_code() const noexcept;
34227825Stheraven    const char* name() const noexcept;
35227825Stheraven};
36227825Stheraven
37227825Stheraventemplate <>
38227825Stheravenstruct hash<type_index>
39227825Stheraven    : public unary_function<type_index, size_t>
40227825Stheraven{
41227825Stheraven    size_t operator()(type_index index) const noexcept;
42227825Stheraven};
43227825Stheraven
44227825Stheraven}  // std
45227825Stheraven
46227825Stheraven*/
47227825Stheraven
48227825Stheraven#include <__config>
49227825Stheraven#include <typeinfo>
50227825Stheraven#include <__functional_base>
51227825Stheraven
52227825Stheraven#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
53227825Stheraven#pragma GCC system_header
54227825Stheraven#endif
55227825Stheraven
56227825Stheraven_LIBCPP_BEGIN_NAMESPACE_STD
57227825Stheraven
58262801Sdimclass _LIBCPP_TYPE_VIS_ONLY type_index
59227825Stheraven{
60227825Stheraven    const type_info* __t_;
61227825Stheravenpublic:
62227825Stheraven    _LIBCPP_INLINE_VISIBILITY
63227825Stheraven    type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}
64227825Stheraven
65227825Stheraven    _LIBCPP_INLINE_VISIBILITY
66227825Stheraven    bool operator==(const type_index& __y) const _NOEXCEPT
67227825Stheraven        {return *__t_ == *__y.__t_;}
68227825Stheraven    _LIBCPP_INLINE_VISIBILITY
69227825Stheraven    bool operator!=(const type_index& __y) const _NOEXCEPT
70227825Stheraven        {return *__t_ != *__y.__t_;}
71227825Stheraven    _LIBCPP_INLINE_VISIBILITY
72227825Stheraven    bool operator< (const type_index& __y) const _NOEXCEPT
73227825Stheraven        {return  __t_->before(*__y.__t_);}
74227825Stheraven    _LIBCPP_INLINE_VISIBILITY
75227825Stheraven    bool operator<=(const type_index& __y) const _NOEXCEPT
76227825Stheraven        {return !__y.__t_->before(*__t_);}
77227825Stheraven    _LIBCPP_INLINE_VISIBILITY
78227825Stheraven    bool operator> (const type_index& __y) const _NOEXCEPT
79227825Stheraven        {return  __y.__t_->before(*__t_);}
80227825Stheraven    _LIBCPP_INLINE_VISIBILITY
81227825Stheraven    bool operator>=(const type_index& __y) const _NOEXCEPT
82227825Stheraven        {return !__t_->before(*__y.__t_);}
83227825Stheraven
84227825Stheraven    _LIBCPP_INLINE_VISIBILITY
85227825Stheraven    size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
86227825Stheraven    _LIBCPP_INLINE_VISIBILITY
87227825Stheraven    const char* name() const _NOEXCEPT {return __t_->name();}
88227825Stheraven};
89227825Stheraven
90262801Sdimtemplate <class _Tp> struct _LIBCPP_TYPE_VIS_ONLY hash;
91227825Stheraven
92227825Stheraventemplate <>
93262801Sdimstruct _LIBCPP_TYPE_VIS_ONLY hash<type_index>
94227825Stheraven    : public unary_function<type_index, size_t>
95227825Stheraven{
96227825Stheraven    _LIBCPP_INLINE_VISIBILITY
97227825Stheraven    size_t operator()(type_index __index) const _NOEXCEPT
98227825Stheraven        {return __index.hash_code();}
99227825Stheraven};
100227825Stheraven
101227825Stheraven_LIBCPP_END_NAMESPACE_STD
102227825Stheraven
103227825Stheraven#endif  // _LIBCPP_TYPEINDEX
104