Debian Codegraph @

libcxx/test/std/utilities/expected/expected.unexpected/assign/assign.copy.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
7
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
9
10 // constexpr unexpected& operator=(const unexpected&) = default;
11
12 #include <cassert>
13 #include <expected>
14
15 struct Error {
16 int i;
17 constexpr Error(int ii) : i(ii) {}
18 };
19
20 constexpr bool test() {
21 std::unexpected<Error> unex1(4);
22 const std::unexpected<Error> unex2(5);
23 unex1 = unex2;
24 assert(unex1.error().i == 5);
25 return true;
26 }
27
28 int main(int, char**) {
29 test();
30 static_assert(test());
31 return 0;
32 }