blob: 49abba2954e5df7d762f4e78850994674751b8d2 [file] [log] [blame]
Eric Fiselier80e66ac2016-11-23 01:02:51 +00001// -*- C++ -*-
2//===----------------------------------------------------------------------===//
3//
4// The LLVM Compiler Infrastructure
5//
6// This file is dual licensed under the MIT and the University of Illinois Open
7// Source Licenses. See LICENSE.TXT for details.
8//
9//===----------------------------------------------------------------------===//
10
11// UNSUPPORTED: c++98, c++03, c++11, c++14
12
13// <variant>
14
15// constexpr bool operator<(monostate, monostate) noexcept { return false; }
16// constexpr bool operator>(monostate, monostate) noexcept { return false; }
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 true; }
20// constexpr bool operator!=(monostate, monostate) noexcept { return false; }
21
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000022#include "test_macros.h"
Eric Fiselier80e66ac2016-11-23 01:02:51 +000023#include <cassert>
24#include <type_traits>
25#include <variant>
26
27int main() {
28 using M = std::monostate;
29 constexpr M m1{};
30 constexpr M m2{};
31 {
32 static_assert((m1 < m2) == false, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000033 ASSERT_NOEXCEPT(m1 < m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000034 }
35 {
36 static_assert((m1 > m2) == false, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000037 ASSERT_NOEXCEPT(m1 > m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000038 }
39 {
40 static_assert((m1 <= m2) == true, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000041 ASSERT_NOEXCEPT(m1 <= m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000042 }
43 {
44 static_assert((m1 >= m2) == true, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000045 ASSERT_NOEXCEPT(m1 >= m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000046 }
47 {
48 static_assert((m1 == m2) == true, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000049 ASSERT_NOEXCEPT(m1 == m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000050 }
51 {
52 static_assert((m1 != m2) == false, "");
Eric Fiselier0d3d8de2016-12-02 23:00:05 +000053 ASSERT_NOEXCEPT(m1 != m2);
Eric Fiselier80e66ac2016-11-23 01:02:51 +000054 }
55}