Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:45

0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009 
0010 #ifndef _LIBCPP___CXX03___VARIANT_MONOSTATE_H
0011 #define _LIBCPP___CXX03___VARIANT_MONOSTATE_H
0012 
0013 #include <__cxx03/__compare/ordering.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/__functional/hash.h>
0016 #include <__cxx03/cstddef>
0017 
0018 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0019 #  pragma GCC system_header
0020 #endif
0021 
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023 
0024 #if _LIBCPP_STD_VER >= 17
0025 
0026 struct _LIBCPP_TEMPLATE_VIS monostate {};
0027 
0028 _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(monostate, monostate) noexcept { return true; }
0029 
0030 #  if _LIBCPP_STD_VER >= 20
0031 
0032 _LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(monostate, monostate) noexcept {
0033   return strong_ordering::equal;
0034 }
0035 
0036 #  else // _LIBCPP_STD_VER >= 20
0037 
0038 _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator!=(monostate, monostate) noexcept { return false; }
0039 
0040 _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<(monostate, monostate) noexcept { return false; }
0041 
0042 _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>(monostate, monostate) noexcept { return false; }
0043 
0044 _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<=(monostate, monostate) noexcept { return true; }
0045 
0046 _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(monostate, monostate) noexcept { return true; }
0047 
0048 #  endif // _LIBCPP_STD_VER >= 20
0049 
0050 template <>
0051 struct _LIBCPP_TEMPLATE_VIS hash<monostate> {
0052   using argument_type = monostate;
0053   using result_type   = size_t;
0054 
0055   inline _LIBCPP_HIDE_FROM_ABI result_type operator()(const argument_type&) const _NOEXCEPT {
0056     return 66740831; // return a fundamentally attractive random value.
0057   }
0058 };
0059 
0060 #endif // _LIBCPP_STD_VER >= 17
0061 
0062 _LIBCPP_END_NAMESPACE_STD
0063 
0064 #endif // _LIBCPP___CXX03___VARIANT_MONOSTATE_H