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-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14
10
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++20
20
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 > 17
35 assert(testOrder(m1, m2, std::strong_ordering::equal));
36 AssertOrderAreNoexcept<M>();
37#endif // TEST_STD_VER > 17
38
39 return true;
40}
41
42int main(int, char**) {
43 test();
44 static_assert(test());
45
46 return 0;
47}
48

source code of libcxx/test/std/utilities/variant/variant.monostate.relops/relops.pass.cpp