mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 22:06:36 +00:00
48 lines
1.5 KiB
C++
48 lines
1.5 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// REQUIRES: std-at-least-c++26
|
|
|
|
// <utility>
|
|
|
|
// constexpr bool operator<(monostate, monostate) noexcept { return false; }
|
|
// constexpr bool operator>(monostate, monostate) noexcept { return false; }
|
|
// constexpr bool operator<=(monostate, monostate) noexcept { return true; }
|
|
// constexpr bool operator>=(monostate, monostate) noexcept { return true; }
|
|
// constexpr bool operator==(monostate, monostate) noexcept { return true; }
|
|
// constexpr bool operator!=(monostate, monostate) noexcept { return false; }
|
|
// constexpr strong_ordering operator<=>(monostate, monostate) noexcept { return strong_ordering::equal; } // since C++20
|
|
|
|
#include <cassert>
|
|
#include <utility>
|
|
|
|
#include "test_comparisons.h"
|
|
#include "test_macros.h"
|
|
|
|
constexpr bool test() {
|
|
using M = std::monostate;
|
|
constexpr M m1{};
|
|
constexpr M m2{};
|
|
assert(testComparisons(m1, m2, /*isEqual*/ true, /*isLess*/ false));
|
|
AssertComparisonsAreNoexcept<M>();
|
|
|
|
#if TEST_STD_VER > 17
|
|
assert(testOrder(m1, m2, std::strong_ordering::equal));
|
|
AssertOrderAreNoexcept<M>();
|
|
#endif // TEST_STD_VER > 17
|
|
|
|
return true;
|
|
}
|
|
|
|
int main(int, char**) {
|
|
test();
|
|
static_assert(test());
|
|
|
|
return 0;
|
|
}
|