blob: 2df4b2bacf5c86f7e4d45f2e88d03b4eb178600c [file] [log] [blame]
Eric Fiselier80e66ac2016-11-23 01:02:51 +00001// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
Chandler Carruth57b08b02019-01-19 10:56:40 +00004// 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-exception
Eric Fiselier80e66ac2016-11-23 01:02:51 +00007//
8//===----------------------------------------------------------------------===//
9
10// UNSUPPORTED: c++98, c++03, c++11, c++14
11
12// <variant>
13
14// constexpr bool operator<(monostate, monostate) noexcept { return false; }
15// constexpr bool operator>(monostate, monostate) noexcept { return false; }
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 true; }
19// constexpr bool operator!=(monostate, monostate) noexcept { return false; }
20
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000021#include "test_macros.h"
Eric Fiselier80e66ac2016-11-23 01:02:51 +000022#include <cassert>
23#include <type_traits>
24#include <variant>
25
26int main() {
27 using M = std::monostate;
28 constexpr M m1{};
29 constexpr M m2{};
30 {
31 static_assert((m1 < m2) == false, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000032 ASSERT_NOEXCEPT(m1 < m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000033 }
34 {
35 static_assert((m1 > m2) == false, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000036 ASSERT_NOEXCEPT(m1 > m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000037 }
38 {
39 static_assert((m1 <= m2) == true, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000040 ASSERT_NOEXCEPT(m1 <= m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000041 }
42 {
43 static_assert((m1 >= m2) == true, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000044 ASSERT_NOEXCEPT(m1 >= m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000045 }
46 {
47 static_assert((m1 == m2) == true, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000048 ASSERT_NOEXCEPT(m1 == m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000049 }
50 {
51 static_assert((m1 != m2) == false, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000052 ASSERT_NOEXCEPT(m1 != m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000053 }
54}