xref: /llvm-project/libcxx/test/std/utilities/expected/expected.unexpected/ctor/ctor.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(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   const std::unexpected<Error> unex(5);
23   auto unex2 = unex;
24   assert(unex2.error().i == 5);
25   return true;
26 }
27 
28 int main(int, char**) {
29   test();
30   static_assert(test());
31   return 0;
32 }
33