typeindex revision 227825
190868Smike// -*- C++ -*-
280708Sjake//===-------------------------- typeindex ---------------------------------===//
380708Sjake//
480708Sjake//                     The LLVM Compiler Infrastructure
580708Sjake//
680708Sjake// This file is dual licensed under the MIT and the University of Illinois Open
780708Sjake// Source Licenses. See LICENSE.TXT for details.
880708Sjake//
980708Sjake//===----------------------------------------------------------------------===//
1080708Sjake
1180708Sjake#ifndef _LIBCPP_TYPEINDEX
1280708Sjake#define _LIBCPP_TYPEINDEX
1390868Smike
1490868Smike/*
1590868Smike
1680708Sjake    typeindex synopsis
1780708Sjake
1880708Sjakenamespace std
1980708Sjake{
2080708Sjake
2180708Sjakeclass type_index
2280708Sjake{
2380708Sjakepublic:
2480708Sjake    type_index(const type_info& rhs) noexcept;
2580708Sjake
2680708Sjake    bool operator==(const type_index& rhs) const noexcept;
2780708Sjake    bool operator!=(const type_index& rhs) const noexcept;
2880708Sjake    bool operator< (const type_index& rhs) const noexcept;
2980708Sjake    bool operator<=(const type_index& rhs) const noexcept;
3080708Sjake    bool operator> (const type_index& rhs) const noexcept;
3180708Sjake    bool operator>=(const type_index& rhs) const noexcept;
3280708Sjake
3380708Sjake    size_t hash_code() const noexcept;
3480708Sjake    const char* name() const noexcept;
3580708Sjake};
3694512Smike
37102227Smiketemplate <>
3890868Smikestruct hash<type_index>
3980708Sjake    : public unary_function<type_index, size_t>
4080708Sjake{
4180708Sjake    size_t operator()(type_index index) const noexcept;
4296672Sobrien};
4396672Sobrien
4480708Sjake}  // std
4580708Sjake
4680708Sjake*/
4780708Sjake
4880708Sjake#include <__config>
4994362Smike#include <typeinfo>
5094362Smike#include <__functional_base>
5194362Smike
5280708Sjake#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
5394362Smike#pragma GCC system_header
5480708Sjake#endif
5594362Smike
5694362Smike_LIBCPP_BEGIN_NAMESPACE_STD
5794362Smike
5894362Smikeclass _LIBCPP_VISIBLE type_index
5994362Smike{
6094362Smike    const type_info* __t_;
6194362Smikepublic:
6294362Smike    _LIBCPP_INLINE_VISIBILITY
6394362Smike    type_index(const type_info& __y) _NOEXCEPT : __t_(&__y) {}
6494362Smike
6594362Smike    _LIBCPP_INLINE_VISIBILITY
66143063Sjoerg    bool operator==(const type_index& __y) const _NOEXCEPT
67120611Smux        {return *__t_ == *__y.__t_;}
68120611Smux    _LIBCPP_INLINE_VISIBILITY
69120611Smux    bool operator!=(const type_index& __y) const _NOEXCEPT
70120611Smux        {return *__t_ != *__y.__t_;}
7191959Smike    _LIBCPP_INLINE_VISIBILITY
72213578Smarius    bool operator< (const type_index& __y) const _NOEXCEPT
73213578Smarius        {return  __t_->before(*__y.__t_);}
74213578Smarius    _LIBCPP_INLINE_VISIBILITY
75213578Smarius    bool operator<=(const type_index& __y) const _NOEXCEPT
76213578Smarius        {return !__y.__t_->before(*__t_);}
77213578Smarius    _LIBCPP_INLINE_VISIBILITY
78213578Smarius    bool operator> (const type_index& __y) const _NOEXCEPT
79213578Smarius        {return  __y.__t_->before(*__t_);}
80213578Smarius    _LIBCPP_INLINE_VISIBILITY
81213578Smarius    bool operator>=(const type_index& __y) const _NOEXCEPT
82213578Smarius        {return !__t_->before(*__y.__t_);}
83213578Smarius
84213578Smarius    _LIBCPP_INLINE_VISIBILITY
85213578Smarius    size_t hash_code() const _NOEXCEPT {return __t_->hash_code();}
86120611Smux    _LIBCPP_INLINE_VISIBILITY
8791959Smike    const char* name() const _NOEXCEPT {return __t_->name();}
88120611Smux};
8991959Smike
9091959Smiketemplate <class _Tp> struct _LIBCPP_VISIBLE hash;
9191959Smike
9291959Smiketemplate <>
9391959Smikestruct _LIBCPP_VISIBLE hash<type_index>
9491959Smike    : public unary_function<type_index, size_t>
95120611Smux{
9691959Smike    _LIBCPP_INLINE_VISIBILITY
9791959Smike    size_t operator()(type_index __index) const _NOEXCEPT
9891959Smike        {return __index.hash_code();}
9991959Smike};
10091959Smike
10191959Smike_LIBCPP_END_NAMESPACE_STD
10291959Smike
103120611Smux#endif  // _LIBCPP_TYPEINDEX
10491959Smike