1// -*- C++ -*- 2//===----------------------------------------------------------------------===// 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 <compare> 50#include <typeinfo> 51#include <version> 52 53// TODO: remove these headers 54#include <__functional/binary_function.h> 55#include <__functional/invoke.h> 56#include <__functional/operations.h> 57#include <__functional/reference_wrapper.h> 58#include <__functional/weak_result_type.h> 59#include <__memory/allocator_arg_t.h> 60#include <__memory/uses_allocator.h> 61#include <new> 62#include <utility> 63 64#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 65# pragma GCC system_header 66#endif 67 68_LIBCPP_BEGIN_NAMESPACE_STD 69 70class _LIBCPP_TEMPLATE_VIS type_index 71{ 72 const type_info* __t_; 73public: 74 _LIBCPP_INLINE_VISIBILITY 75 type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {} 76 77 _LIBCPP_INLINE_VISIBILITY 78 bool operator==(const type_index& __y) const _NOEXCEPT 79 {return *__t_ == *__y.__t_;} 80 _LIBCPP_INLINE_VISIBILITY 81 bool operator!=(const type_index& __y) const _NOEXCEPT 82 {return *__t_ != *__y.__t_;} 83 _LIBCPP_INLINE_VISIBILITY 84 bool operator< (const type_index& __y) const _NOEXCEPT 85 {return __t_->before(*__y.__t_);} 86 _LIBCPP_INLINE_VISIBILITY 87 bool operator<=(const type_index& __y) const _NOEXCEPT 88 {return !__y.__t_->before(*__t_);} 89 _LIBCPP_INLINE_VISIBILITY 90 bool operator> (const type_index& __y) const _NOEXCEPT 91 {return __y.__t_->before(*__t_);} 92 _LIBCPP_INLINE_VISIBILITY 93 bool operator>=(const type_index& __y) const _NOEXCEPT 94 {return !__t_->before(*__y.__t_);} 95 96 _LIBCPP_INLINE_VISIBILITY 97 size_t hash_code() const _NOEXCEPT {return __t_->hash_code();} 98 _LIBCPP_INLINE_VISIBILITY 99 const char* name() const _NOEXCEPT {return __t_->name();} 100}; 101 102template <class _Tp> struct _LIBCPP_TEMPLATE_VIS hash; 103 104template <> 105struct _LIBCPP_TEMPLATE_VIS hash<type_index> 106 : public unary_function<type_index, size_t> 107{ 108 _LIBCPP_INLINE_VISIBILITY 109 size_t operator()(type_index __index) const _NOEXCEPT 110 {return __index.hash_code();} 111}; 112 113_LIBCPP_END_NAMESPACE_STD 114 115#endif // _LIBCPP_TYPEINDEX 116