|
||||
File indexing completed on 2025-01-18 09:27:30
0001 // Copyright 2018 The Abseil Authors. 0002 // 0003 // Licensed under the Apache License, Version 2.0 (the "License"); 0004 // you may not use this file except in compliance with the License. 0005 // You may obtain a copy of the License at 0006 // 0007 // https://www.apache.org/licenses/LICENSE-2.0 0008 // 0009 // Unless required by applicable law or agreed to in writing, software 0010 // distributed under the License is distributed on an "AS IS" BASIS, 0011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0012 // See the License for the specific language governing permissions and 0013 // limitations under the License. 0014 // 0015 // ----------------------------------------------------------------------------- 0016 // bad_optional_access.h 0017 // ----------------------------------------------------------------------------- 0018 // 0019 // This header file defines the `absl::bad_optional_access` type. 0020 0021 #ifndef ABSL_TYPES_BAD_OPTIONAL_ACCESS_H_ 0022 #define ABSL_TYPES_BAD_OPTIONAL_ACCESS_H_ 0023 0024 #include <stdexcept> 0025 0026 #include "absl/base/config.h" 0027 0028 #ifdef ABSL_USES_STD_OPTIONAL 0029 0030 #include <optional> 0031 0032 namespace absl { 0033 ABSL_NAMESPACE_BEGIN 0034 using std::bad_optional_access; 0035 ABSL_NAMESPACE_END 0036 } // namespace absl 0037 0038 #else // ABSL_USES_STD_OPTIONAL 0039 0040 namespace absl { 0041 ABSL_NAMESPACE_BEGIN 0042 0043 // ----------------------------------------------------------------------------- 0044 // bad_optional_access 0045 // ----------------------------------------------------------------------------- 0046 // 0047 // An `absl::bad_optional_access` type is an exception type that is thrown when 0048 // attempting to access an `absl::optional` object that does not contain a 0049 // value. 0050 // 0051 // Example: 0052 // 0053 // absl::optional<int> o; 0054 // 0055 // try { 0056 // int n = o.value(); 0057 // } catch(const absl::bad_optional_access& e) { 0058 // std::cout << "Bad optional access: " << e.what() << '\n'; 0059 // } 0060 class bad_optional_access : public std::exception { 0061 public: 0062 bad_optional_access() = default; 0063 ~bad_optional_access() override; 0064 const char* what() const noexcept override; 0065 }; 0066 0067 namespace optional_internal { 0068 0069 // throw delegator 0070 [[noreturn]] ABSL_DLL void throw_bad_optional_access(); 0071 0072 } // namespace optional_internal 0073 ABSL_NAMESPACE_END 0074 } // namespace absl 0075 0076 #endif // ABSL_USES_STD_OPTIONAL 0077 0078 #endif // ABSL_TYPES_BAD_OPTIONAL_ACCESS_H_
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |