| 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(unexpected&&) = default; |
| 11 |
|
| 12 |
#include <cassert> |
| 13 |
#include <expected> |
| 14 |
#include <utility> |
| 15 |
|
| 16 |
struct Error { |
| 17 |
int i; |
| 18 |
constexpr Error(int ii) : i(ii) {} |
| 19 |
constexpr Error(Error&& other) : i(other.i) {other.i = 0;} |
| 20 |
}; |
| 21 |
|
| 22 |
constexpr bool test() { |
| 23 |
std::unexpected<Error> unex(5); |
| 24 |
auto unex2 = std::move(unex); |
| 25 |
assert(unex2.error().i == 5); |
| 26 |
assert(unex.error().i == 0); |
| 27 |
return true; |
| 28 |
} |
| 29 |
|
| 30 |
int main(int, char**) { |
| 31 |
test(); |
| 32 |
static_assert(test()); |
| 33 |
return 0; |
| 34 |
} |