Path: blob/main/contrib/llvm-project/libcxx/include/__variant/monostate.h
35262 views
// -*- C++ -*-1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//89#ifndef _LIBCPP___VARIANT_MONOSTATE_H10#define _LIBCPP___VARIANT_MONOSTATE_H1112#include <__compare/ordering.h>13#include <__config>14#include <__functional/hash.h>15#include <cstddef>1617#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18# pragma GCC system_header19#endif2021_LIBCPP_BEGIN_NAMESPACE_STD2223#if _LIBCPP_STD_VER >= 172425struct _LIBCPP_TEMPLATE_VIS monostate {};2627_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(monostate, monostate) noexcept { return true; }2829# if _LIBCPP_STD_VER >= 203031_LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(monostate, monostate) noexcept {32return strong_ordering::equal;33}3435# else // _LIBCPP_STD_VER >= 203637_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator!=(monostate, monostate) noexcept { return false; }3839_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<(monostate, monostate) noexcept { return false; }4041_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>(monostate, monostate) noexcept { return false; }4243_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator<=(monostate, monostate) noexcept { return true; }4445_LIBCPP_HIDE_FROM_ABI inline constexpr bool operator>=(monostate, monostate) noexcept { return true; }4647# endif // _LIBCPP_STD_VER >= 204849template <>50struct _LIBCPP_TEMPLATE_VIS hash<monostate> {51using argument_type = monostate;52using result_type = size_t;5354inline _LIBCPP_HIDE_FROM_ABI result_type operator()(const argument_type&) const _NOEXCEPT {55return 66740831; // return a fundamentally attractive random value.56}57};5859#endif // _LIBCPP_STD_VER >= 176061_LIBCPP_END_NAMESPACE_STD6263#endif // _LIBCPP___VARIANT_MONOSTATE_H646566