[mlir][tensor] fix typo in pad tiling comment
[llvm-project.git] / libcxx / test / std / utilities / expected / expected.void / equality / equality.other_expected.pass.cpp
blob8b24875586852f3306c5c7502bd4890129fbccc0
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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
11 // template<class T2, class E2> requires (is_void_v<T2>)
12 // friend constexpr bool operator==(const expected& x, const expected<T2, E2>& y);
14 #include <cassert>
15 #include <concepts>
16 #include <expected>
17 #include <type_traits>
18 #include <utility>
20 #include "test_macros.h"
22 // Test constraint
23 template <class T1, class T2>
24 concept CanCompare = requires(T1 t1, T2 t2) { t1 == t2; };
26 struct Foo{};
27 static_assert(!CanCompare<Foo, Foo>);
29 static_assert(CanCompare<std::expected<void, int>, std::expected<void, int>>);
30 static_assert(CanCompare<std::expected<void, int>, std::expected<void, short>>);
32 // Note this is true because other overloads in expected<non-void> are unconstrained
33 static_assert(CanCompare<std::expected<void, int>, std::expected<int, int>>);
35 constexpr bool test() {
36 // x.has_value() && y.has_value()
38 const std::expected<void, int> e1;
39 const std::expected<void, int> e2;
40 assert(e1 == e2);
43 // !x.has_value() && y.has_value()
45 const std::expected<void, int> e1(std::unexpect, 5);
46 const std::expected<void, int> e2;
47 assert(e1 != e2);
50 // x.has_value() && !y.has_value()
52 const std::expected<void, int> e1;
53 const std::expected<void, int> e2(std::unexpect, 10);
54 const std::expected<void, int> e3(std::unexpect, 5);
55 assert(e1 != e2);
56 assert(e1 != e3);
59 // !x.has_value() && !y.has_value()
61 const std::expected<void, int> e1(std::unexpect, 5);
62 const std::expected<void, int> e2(std::unexpect, 10);
63 const std::expected<void, int> e3(std::unexpect, 5);
64 assert(e1 != e2);
65 assert(e1 == e3);
68 return true;
71 int main(int, char**) {
72 test();
73 static_assert(test());
74 return 0;