xref: /llvm-project/libcxx/test/std/utilities/expected/expected.unexpected/assign/assign.copy.pass.cpp (revision 6a54dfbfe534276d644d7f9c027f0deeb748dd53)
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 //===----------------------------------------------------------------------===//
8 
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
10 
11 // constexpr unexpected& operator=(const unexpected&) = default;
12 
13 #include <cassert>
14 #include <expected>
15 
16 struct Error {
17   int i;
18   constexpr Error(int ii) : i(ii) {}
19 };
20 
21 constexpr bool test() {
22   std::unexpected<Error> unex1(4);
23   const std::unexpected<Error> unex2(5);
24   unex1 = unex2;
25   assert(unex1.error().i == 5);
26   return true;
27 }
28 
29 int main(int, char**) {
30   test();
31   static_assert(test());
32   return 0;
33 }
34