[flang][OpenMP] Use range-for to iterate over SymbolSourceMap, NFC
[llvm-project.git] / libcxx / test / std / utilities / expected / expected.bad / void-specialization.pass.cpp
blob92e2fef9d9f02207352b17ad263aff1a7010dbfd
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-exception
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
11 // template<>
12 // class bad_expected_access<void> : public exception {
13 // protected:
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();
21 // public:
22 // const char* what() const noexcept override;
23 // };
25 #include <cassert>
26 #include <exception>
27 #include <expected>
28 #include <type_traits>
29 #include <utility>
31 #include "test_macros.h"
33 struct Inherit : std::bad_expected_access<void> {};
35 int main(int, char**) {
36 // base class
37 static_assert(std::is_base_of_v<std::exception, std::bad_expected_access<void>>);
39 // default constructor
41 Inherit exc;
42 ASSERT_NOEXCEPT(Inherit());
45 // copy constructor
47 Inherit exc;
48 Inherit copy(exc);
49 ASSERT_NOEXCEPT(Inherit(exc));
52 // move constructor
54 Inherit exc;
55 Inherit copy(std::move(exc));
56 ASSERT_NOEXCEPT(Inherit(std::move(exc)));
59 // copy assignment
61 Inherit exc;
62 Inherit copy;
63 [[maybe_unused]] Inherit& result = (copy = exc);
64 ASSERT_NOEXCEPT(copy = exc);
67 // move assignment
69 Inherit exc;
70 Inherit copy;
71 [[maybe_unused]] Inherit& result = (copy = std::move(exc));
72 ASSERT_NOEXCEPT(copy = std::move(exc));
75 // what()
77 Inherit exc;
78 char const* what = exc.what();
79 assert(what != nullptr);
80 ASSERT_NOEXCEPT(exc.what());
83 return 0;