190075Sobrien// -*- C++ -*- 2169689Skan//===----------------------------------------------------------------------===// 3169689Skan// 490075Sobrien// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 590075Sobrien// See https://llvm.org/LICENSE.txt for license information. 690075Sobrien// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 790075Sobrien// 890075Sobrien//===----------------------------------------------------------------------===// 990075Sobrien 1090075Sobrien#ifndef _LIBCPP_TYPEINDEX 1190075Sobrien#define _LIBCPP_TYPEINDEX 1290075Sobrien 1390075Sobrien/* 1490075Sobrien 1590075Sobrien typeindex synopsis 1690075Sobrien 17169689Skannamespace std 1890075Sobrien{ 1990075Sobrien 2090075Sobrienclass type_index 2190075Sobrien{ 2290075Sobrienpublic: 2390075Sobrien type_index(const type_info& rhs) noexcept; 2490075Sobrien 2590075Sobrien bool operator==(const type_index& rhs) const noexcept; 2690075Sobrien bool operator!=(const type_index& rhs) const noexcept; // removed in C++20 2790075Sobrien bool operator< (const type_index& rhs) const noexcept; 2890075Sobrien bool operator<=(const type_index& rhs) const noexcept; 2990075Sobrien bool operator> (const type_index& rhs) const noexcept; 3090075Sobrien bool operator>=(const type_index& rhs) const noexcept; 3190075Sobrien strong_ordering operator<=>(const type_index& rhs) const noexcept; // C++20 3290075Sobrien 3390075Sobrien size_t hash_code() const noexcept; 3490075Sobrien const char* name() const noexcept; 3590075Sobrien}; 3690075Sobrien 3790075Sobrientemplate <> 3890075Sobrienstruct hash<type_index> 3990075Sobrien : public unary_function<type_index, size_t> 4090075Sobrien{ 4190075Sobrien size_t operator()(type_index index) const noexcept; 4290075Sobrien}; 4390075Sobrien 4490075Sobrien} // std 4590075Sobrien 4690075Sobrien*/ 4790075Sobrien 48169689Skan#include <__assert> // all public C++ headers provide the assertion handler 49169689Skan#include <__config> 50169689Skan#include <__functional/unary_function.h> 51132718Skan#include <typeinfo> 52169689Skan#include <version> 53132718Skan 54169689Skan// standard-mandated includes 55169689Skan#include <compare> 56169689Skan 57169689Skan#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 58169689Skan# pragma GCC system_header 59169689Skan#endif 60169689Skan 61169689Skan_LIBCPP_BEGIN_NAMESPACE_STD 62169689Skan 63169689Skanclass _LIBCPP_TEMPLATE_VIS type_index { 64169689Skan const type_info* __t_; 65169689Skan 66169689Skanpublic: 67169689Skan _LIBCPP_HIDE_FROM_ABI type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {} 68169689Skan 69169689Skan _LIBCPP_HIDE_FROM_ABI bool operator==(const type_index& __y) const _NOEXCEPT { return *__t_ == *__y.__t_; } 70169689Skan#if _LIBCPP_STD_VER <= 17 71169689Skan _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_index& __y) const _NOEXCEPT { return *__t_ != *__y.__t_; } 7290075Sobrien#endif 7390075Sobrien _LIBCPP_HIDE_FROM_ABI bool operator<(const type_index& __y) const _NOEXCEPT { return __t_->before(*__y.__t_); } 7490075Sobrien _LIBCPP_HIDE_FROM_ABI bool operator<=(const type_index& __y) const _NOEXCEPT { return !__y.__t_->before(*__t_); } 7590075Sobrien _LIBCPP_HIDE_FROM_ABI bool operator>(const type_index& __y) const _NOEXCEPT { return __y.__t_->before(*__t_); } 7690075Sobrien _LIBCPP_HIDE_FROM_ABI bool operator>=(const type_index& __y) const _NOEXCEPT { return !__t_->before(*__y.__t_); } 7790075Sobrien#if _LIBCPP_STD_VER >= 20 7890075Sobrien _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const type_index& __y) const noexcept { 7990075Sobrien if (*__t_ == *__y.__t_) 8090075Sobrien return strong_ordering::equal; 8190075Sobrien if (__t_->before(*__y.__t_)) 8290075Sobrien return strong_ordering::less; 8390075Sobrien return strong_ordering::greater; 8490075Sobrien } 8590075Sobrien#endif 8690075Sobrien 8790075Sobrien _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __t_->hash_code(); } 8890075Sobrien _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { return __t_->name(); } 8990075Sobrien}; 9090075Sobrien 9190075Sobrientemplate <class _Tp> 9290075Sobrienstruct _LIBCPP_TEMPLATE_VIS hash; 9390075Sobrien 9490075Sobrientemplate <> 95132718Skanstruct _LIBCPP_TEMPLATE_VIS hash<type_index> : public __unary_function<type_index, size_t> { 9690075Sobrien _LIBCPP_HIDE_FROM_ABI size_t operator()(type_index __index) const _NOEXCEPT { return __index.hash_code(); } 97117395Skan}; 98132718Skan 99117395Skan_LIBCPP_END_NAMESPACE_STD 100169689Skan 101169689Skan#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 102169689Skan# include <iosfwd> 103169689Skan# include <new> 104169689Skan# include <utility> 105169689Skan#endif 106169689Skan 107169689Skan#endif // _LIBCPP_TYPEINDEX 108169689Skan