Eric Fiselier | 80e66ac | 2016-11-23 01:02:51 +0000 | [diff] [blame] | 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 <cassert> |
| 23 | #include <type_traits> |
| 24 | #include <variant> |
| 25 | |
| 26 | int main() { |
| 27 | using M = std::monostate; |
| 28 | constexpr M m1{}; |
| 29 | constexpr M m2{}; |
| 30 | { |
| 31 | static_assert((m1 < m2) == false, ""); |
| 32 | static_assert(noexcept(m1 < m2), ""); |
| 33 | } |
| 34 | { |
| 35 | static_assert((m1 > m2) == false, ""); |
| 36 | static_assert(noexcept(m1 > m2), ""); |
| 37 | } |
| 38 | { |
| 39 | static_assert((m1 <= m2) == true, ""); |
| 40 | static_assert(noexcept(m1 <= m2), ""); |
| 41 | } |
| 42 | { |
| 43 | static_assert((m1 >= m2) == true, ""); |
| 44 | static_assert(noexcept(m1 >= m2), ""); |
| 45 | } |
| 46 | { |
| 47 | static_assert((m1 == m2) == true, ""); |
| 48 | static_assert(noexcept(m1 == m2), ""); |
| 49 | } |
| 50 | { |
| 51 | static_assert((m1 != m2) == false, ""); |
| 52 | static_assert(noexcept(m1 != m2), ""); |
| 53 | } |
| 54 | } |