• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // -*- 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 
22 #include "test_macros.h"
23 #include <cassert>
24 #include <type_traits>
25 #include <variant>
26 
main()27 int main() {
28   using M = std::monostate;
29   constexpr M m1{};
30   constexpr M m2{};
31   {
32     static_assert((m1 < m2) == false, "");
33     ASSERT_NOEXCEPT(m1 < m2);
34   }
35   {
36     static_assert((m1 > m2) == false, "");
37     ASSERT_NOEXCEPT(m1 > m2);
38   }
39   {
40     static_assert((m1 <= m2) == true, "");
41     ASSERT_NOEXCEPT(m1 <= m2);
42   }
43   {
44     static_assert((m1 >= m2) == true, "");
45     ASSERT_NOEXCEPT(m1 >= m2);
46   }
47   {
48     static_assert((m1 == m2) == true, "");
49     ASSERT_NOEXCEPT(m1 == m2);
50   }
51   {
52     static_assert((m1 != m2) == false, "");
53     ASSERT_NOEXCEPT(m1 != m2);
54   }
55 }
56