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