bad_optional_access.h
Go to the documentation of this file.
00001 // Copyright 2018 The Abseil Authors.
00002 //
00003 // Licensed under the Apache License, Version 2.0 (the "License");
00004 // you may not use this file except in compliance with the License.
00005 // You may obtain a copy of the License at
00006 //
00007 //      https://www.apache.org/licenses/LICENSE-2.0
00008 //
00009 // Unless required by applicable law or agreed to in writing, software
00010 // distributed under the License is distributed on an "AS IS" BASIS,
00011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00012 // See the License for the specific language governing permissions and
00013 // limitations under the License.
00014 //
00015 // -----------------------------------------------------------------------------
00016 // bad_optional_access.h
00017 // -----------------------------------------------------------------------------
00018 //
00019 // This header file defines the `absl::bad_optional_access` type.
00020 
00021 #ifndef ABSL_TYPES_BAD_OPTIONAL_ACCESS_H_
00022 #define ABSL_TYPES_BAD_OPTIONAL_ACCESS_H_
00023 
00024 #include <stdexcept>
00025 
00026 #include "absl/base/config.h"
00027 
00028 #ifdef ABSL_HAVE_STD_OPTIONAL
00029 
00030 #include <optional>
00031 
00032 namespace absl {
00033 using std::bad_optional_access;
00034 }  // namespace absl
00035 
00036 #else  // ABSL_HAVE_STD_OPTIONAL
00037 
00038 namespace absl {
00039 
00040 // -----------------------------------------------------------------------------
00041 // bad_optional_access
00042 // -----------------------------------------------------------------------------
00043 //
00044 // An `absl::bad_optional_access` type is an exception type that is thrown when
00045 // attempting to access an `absl::optional` object that does not contain a
00046 // value.
00047 //
00048 // Example:
00049 //
00050 //   absl::optional<int> o;
00051 //
00052 //   try {
00053 //     int n = o.value();
00054 //   } catch(const absl::bad_optional_access& e) {
00055 //     std::cout << "Bad optional access: " << e.what() << '\n';
00056 //   }
00057 class bad_optional_access : public std::exception {
00058  public:
00059   bad_optional_access() = default;
00060   ~bad_optional_access() override;
00061   const char* what() const noexcept override;
00062 };
00063 
00064 namespace optional_internal {
00065 
00066 // throw delegator
00067 [[noreturn]] void throw_bad_optional_access();
00068 
00069 }  // namespace optional_internal
00070 }  // namespace absl
00071 
00072 #endif  // ABSL_HAVE_STD_OPTIONAL
00073 
00074 #endif  // ABSL_TYPES_BAD_OPTIONAL_ACCESS_H_


abseil_cpp
Author(s):
autogenerated on Wed Jun 19 2019 19:42:14