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
12 // class bad_expected_access<void> : public exception {
14 // bad_expected_access() noexcept;
15 // bad_expected_access(const bad_expected_access&) noexcept;
16 // bad_expected_access(bad_expected_access&&) noexcept;
17 // bad_expected_access& operator=(const bad_expected_access&) noexcept;
18 // bad_expected_access& operator=(bad_expected_access&&) noexcept;
19 // ~bad_expected_access();
22 // const char* what() const noexcept override;
28 #include <type_traits>
31 #include "test_macros.h"
33 struct Inherit
: std::bad_expected_access
<void> {};
35 int main(int, char**) {
37 static_assert(std::is_base_of_v
<std::exception
, std::bad_expected_access
<void>>);
39 // default constructor
42 ASSERT_NOEXCEPT(Inherit());
49 ASSERT_NOEXCEPT(Inherit(exc
));
55 Inherit
copy(std::move(exc
));
56 ASSERT_NOEXCEPT(Inherit(std::move(exc
)));
63 [[maybe_unused
]] Inherit
& result
= (copy
= exc
);
64 ASSERT_NOEXCEPT(copy
= exc
);
71 [[maybe_unused
]] Inherit
& result
= (copy
= std::move(exc
));
72 ASSERT_NOEXCEPT(copy
= std::move(exc
));
78 char const* what
= exc
.what();
79 assert(what
!= nullptr);
80 ASSERT_NOEXCEPT(exc
.what());