brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · fab67be Raw
48 lines · cpp
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//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++1410 11// <variant>12 13// constexpr bool operator<(monostate, monostate) noexcept { return false; }14// constexpr bool operator>(monostate, monostate) noexcept { return false; }15// constexpr bool operator<=(monostate, monostate) noexcept { return true; }16// constexpr bool operator>=(monostate, monostate) noexcept { return true; }17// constexpr bool operator==(monostate, monostate) noexcept { return true; }18// constexpr bool operator!=(monostate, monostate) noexcept { return false; }19// constexpr strong_ordering operator<=>(monostate, monostate) noexcept { return strong_ordering::equal; } // since C++2020 21#include <cassert>22#include <variant>23 24#include "test_comparisons.h"25#include "test_macros.h"26 27constexpr bool test() {28  using M = std::monostate;29  constexpr M m1{};30  constexpr M m2{};31  assert(testComparisons(m1, m2, /*isEqual*/ true, /*isLess*/ false));32  AssertComparisonsAreNoexcept<M>();33 34#if TEST_STD_VER > 1735  assert(testOrder(m1, m2, std::strong_ordering::equal));36  AssertOrderAreNoexcept<M>();37#endif // TEST_STD_VER > 1738 39  return true;40}41 42int main(int, char**) {43  test();44  static_assert(test());45 46  return 0;47}48