brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · e32cb07 Raw
112 lines · plain
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-exception7//8//===----------------------------------------------------------------------===//9 10#ifndef _LIBCPP_TYPEINDEX11#define _LIBCPP_TYPEINDEX12 13/*14 15    typeindex synopsis16 17namespace std18{19 20class type_index21{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; // removed in C++2027    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    strong_ordering operator<=>(const type_index& rhs) const noexcept; // C++2032 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}  // std45 46*/47 48#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)49#  include <__cxx03/typeindex>50#else51#  include <__config>52#  include <__functional/unary_function.h>53#  include <typeinfo>54#  include <version>55 56// standard-mandated includes57#  include <compare>58 59#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)60#    pragma GCC system_header61#  endif62 63_LIBCPP_BEGIN_NAMESPACE_STD64 65class type_index {66  const type_info* __t_;67 68public:69  _LIBCPP_HIDE_FROM_ABI type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}70 71  _LIBCPP_HIDE_FROM_ABI bool operator==(const type_index& __y) const _NOEXCEPT { return *__t_ == *__y.__t_; }72#  if _LIBCPP_STD_VER <= 1773  _LIBCPP_HIDE_FROM_ABI bool operator!=(const type_index& __y) const _NOEXCEPT { return *__t_ != *__y.__t_; }74#  endif75  _LIBCPP_HIDE_FROM_ABI bool operator<(const type_index& __y) const _NOEXCEPT { return __t_->before(*__y.__t_); }76  _LIBCPP_HIDE_FROM_ABI bool operator<=(const type_index& __y) const _NOEXCEPT { return !__y.__t_->before(*__t_); }77  _LIBCPP_HIDE_FROM_ABI bool operator>(const type_index& __y) const _NOEXCEPT { return __y.__t_->before(*__t_); }78  _LIBCPP_HIDE_FROM_ABI bool operator>=(const type_index& __y) const _NOEXCEPT { return !__t_->before(*__y.__t_); }79#  if _LIBCPP_STD_VER >= 2080  _LIBCPP_HIDE_FROM_ABI strong_ordering operator<=>(const type_index& __y) const noexcept {81    if (*__t_ == *__y.__t_)82      return strong_ordering::equal;83    if (__t_->before(*__y.__t_))84      return strong_ordering::less;85    return strong_ordering::greater;86  }87#  endif88 89  _LIBCPP_HIDE_FROM_ABI size_t hash_code() const _NOEXCEPT { return __t_->hash_code(); }90  _LIBCPP_HIDE_FROM_ABI const char* name() const _NOEXCEPT { return __t_->name(); }91};92 93template <class _Tp>94struct hash;95 96template <>97struct hash<type_index> : public __unary_function<type_index, size_t> {98  _LIBCPP_HIDE_FROM_ABI size_t operator()(type_index __index) const _NOEXCEPT { return __index.hash_code(); }99};100 101_LIBCPP_END_NAMESPACE_STD102 103#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20104#    include <cstddef>105#    include <iosfwd>106#    include <new>107#    include <utility>108#  endif109#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)110 111#endif // _LIBCPP_TYPEINDEX112