1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
11 // E& error() & noexcept;
12 // const E& error() const & noexcept;
13 // E&& error() && noexcept;
14 // const E&& error() const && noexcept;
22 concept ErrorNoexcept
=
24 { std::forward
<T
>(t
).error() } noexcept
;
27 static_assert(!ErrorNoexcept
<int>);
28 static_assert(ErrorNoexcept
<std::bad_expected_access
<int>&>);
29 static_assert(ErrorNoexcept
<std::bad_expected_access
<int> const&>);
30 static_assert(ErrorNoexcept
<std::bad_expected_access
<int>&&>);
31 static_assert(ErrorNoexcept
<std::bad_expected_access
<int> const&&>);
36 std::bad_expected_access
<int> e(5);
37 decltype(auto) i
= e
.error();
38 static_assert(std::same_as
<decltype(i
), int&>);
44 const std::bad_expected_access
<int> e(5);
45 decltype(auto) i
= e
.error();
46 static_assert(std::same_as
<decltype(i
), const int&>);
52 std::bad_expected_access
<int> e(5);
53 decltype(auto) i
= std::move(e
).error();
54 static_assert(std::same_as
<decltype(i
), int&&>);
60 const std::bad_expected_access
<int> e(5);
61 decltype(auto) i
= std::move(e
).error();
62 static_assert(std::same_as
<decltype(i
), const int&&>);
67 int main(int, char**) {