brintos

brintos / llvm-project-archived public Read only

0
0
Text · 832 B · 088ed21 Raw
34 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& operator=(const unexpected&) = default;12 13#include <cassert>14#include <expected>15 16struct Error {17  int i;18  constexpr Error(int ii) : i(ii) {}19};20 21constexpr 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 29int main(int, char**) {30  test();31  static_assert(test());32  return 0;33}34