[rtsan] Remove mkfifoat interceptor (#116997)
[llvm-project.git] / libcxx / include / __cxx03 / __expected / bad_expected_access.h
blob4f7e33d2c69867a91d49c33a6bc5c6e89a1f46b9
1 // -*- C++ -*-
2 //===----------------------------------------------------------------------===//
3 //
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //
8 //===----------------------------------------------------------------------===//
9 #ifndef _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
10 #define _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H
12 #include <__cxx03/__config>
13 #include <__cxx03/__exception/exception.h>
14 #include <__cxx03/__utility/move.h>
16 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17 # pragma GCC system_header
18 #endif
20 _LIBCPP_PUSH_MACROS
21 #include <__cxx03/__undef_macros>
23 #if _LIBCPP_STD_VER >= 23
25 _LIBCPP_BEGIN_NAMESPACE_STD
27 template <class _Err>
28 class bad_expected_access;
30 _LIBCPP_DIAGNOSTIC_PUSH
31 # if !_LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION
32 _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
33 # endif
34 template <>
35 class _LIBCPP_EXPORTED_FROM_ABI bad_expected_access<void> : public exception {
36 protected:
37 _LIBCPP_HIDE_FROM_ABI bad_expected_access() noexcept = default;
38 _LIBCPP_HIDE_FROM_ABI bad_expected_access(const bad_expected_access&) noexcept = default;
39 _LIBCPP_HIDE_FROM_ABI bad_expected_access(bad_expected_access&&) noexcept = default;
40 _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(const bad_expected_access&) noexcept = default;
41 _LIBCPP_HIDE_FROM_ABI bad_expected_access& operator=(bad_expected_access&&) noexcept = default;
42 _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_expected_access() override = default;
44 public:
45 # if _LIBCPP_AVAILABILITY_HAS_BAD_EXPECTED_ACCESS_KEY_FUNCTION
46 const char* what() const noexcept override;
47 # else
48 _LIBCPP_HIDE_FROM_ABI_VIRTUAL const char* what() const noexcept override { return "bad access to std::expected"; }
49 # endif
51 _LIBCPP_DIAGNOSTIC_POP
53 template <class _Err>
54 class bad_expected_access : public bad_expected_access<void> {
55 public:
56 _LIBCPP_HIDE_FROM_ABI explicit bad_expected_access(_Err __e) : __unex_(std::move(__e)) {}
58 _LIBCPP_HIDE_FROM_ABI _Err& error() & noexcept { return __unex_; }
59 _LIBCPP_HIDE_FROM_ABI const _Err& error() const& noexcept { return __unex_; }
60 _LIBCPP_HIDE_FROM_ABI _Err&& error() && noexcept { return std::move(__unex_); }
61 _LIBCPP_HIDE_FROM_ABI const _Err&& error() const&& noexcept { return std::move(__unex_); }
63 private:
64 _Err __unex_;
67 _LIBCPP_END_NAMESPACE_STD
69 #endif // _LIBCPP_STD_VER >= 23
71 _LIBCPP_POP_MACROS
73 #endif // _LIBCPP___EXPECTED_BAD_EXPECTED_ACCESS_H