brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.1 KiB · 3939e42 Raw
67 lines · c
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___VARIANT_MONOSTATE_H11#define _LIBCPP___VARIANT_MONOSTATE_H12 13#include <__compare/ordering.h>14#include <__config>15#include <__cstddef/size_t.h>16#include <__functional/hash.h>17 18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)19#  pragma GCC system_header20#endif21 22_LIBCPP_BEGIN_NAMESPACE_STD23 24#if _LIBCPP_STD_VER >= 1725 26struct monostate {};27 28_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(monostate, monostate) noexcept { return true; }29 30#  if _LIBCPP_STD_VER >= 2031 32_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(monostate, monostate) noexcept {33  return strong_ordering::equal;34}35 36#  else // _LIBCPP_STD_VER >= 2037 38_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator!=(monostate, monostate) noexcept { return false; }39 40_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<(monostate, monostate) noexcept { return false; }41 42_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>(monostate, monostate) noexcept { return false; }43 44_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<=(monostate, monostate) noexcept { return true; }45 46_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(monostate, monostate) noexcept { return true; }47 48#  endif // _LIBCPP_STD_VER >= 2049 50template <>51struct hash<monostate> {52#  if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)53  using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = monostate;54  using result_type _LIBCPP_DEPRECATED_IN_CXX17   = size_t;55#  endif56 57  inline _LIBCPP_HIDE_FROM_ABI size_t operator()(const monostate&) const noexcept {58    return 66740831; // return a fundamentally attractive random value.59  }60};61 62#endif // _LIBCPP_STD_VER >= 1763 64_LIBCPP_END_NAMESPACE_STD65 66#endif // _LIBCPP___VARIANT_MONOSTATE_H67