Debian Codegraph @

libcxx/test/std/utilities/expected/expected.bad/what.pass.cpp

raw
1 //===----------------------------------------------------------------------===//
2 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
3 // See https://llvm.org/LICENSE.txt for license information.
4 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
5 //
6 //===----------------------------------------------------------------------===//
7
8 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
9
10 // const char* what() const noexcept override;
11
12 #include <expected>
13 #include <cassert>
14 #include <utility>
15
16 #include "test_macros.h"
17
18 struct Foo {};
19
20 int main(int, char**) {
21 {
22 std::bad_expected_access<int> const exc(99);
23 char const* what = exc.what();
24 assert(what != nullptr);
25 ASSERT_NOEXCEPT(exc.what());
26 }
27 {
28 std::bad_expected_access<Foo> const exc(Foo{});
29 char const* what = exc.what();
30 assert(what != nullptr);
31 ASSERT_NOEXCEPT(exc.what());
32 }
33
34 return 0;
35 }