brintos

brintos / llvm-project-archived public Read only

0
0
Text · 900 B · 53d4c6b Raw
36 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// UNSUPPORTED: c++03, c++11, c++14, c++17, c++2010 11// constexpr unexpected(unexpected&&) = default;12 13#include <cassert>14#include <expected>15#include <utility>16 17struct Error {18  int i;19  constexpr Error(int ii) : i(ii) {}20  constexpr Error(Error&& other) : i(other.i) {other.i = 0;}21};22 23constexpr bool test() {24  std::unexpected<Error> unex(5);25  auto unex2 = std::move(unex);26  assert(unex2.error().i == 5);27  assert(unex.error().i == 0);28  return true;29}30 31int main(int, char**) {32  test();33  static_assert(test());34  return 0;35}36