bad_any_cast.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_any_cast.h
00017 // -----------------------------------------------------------------------------
00018 //
00019 // This header file defines the `absl::bad_any_cast` type.
00020 
00021 #ifndef ABSL_TYPES_BAD_ANY_CAST_H_
00022 #define ABSL_TYPES_BAD_ANY_CAST_H_
00023 
00024 #include <typeinfo>
00025 
00026 #include "absl/base/config.h"
00027 
00028 #ifdef ABSL_HAVE_STD_ANY
00029 
00030 #include <any>
00031 
00032 namespace absl {
00033 using std::bad_any_cast;
00034 }  // namespace absl
00035 
00036 #else  // ABSL_HAVE_STD_ANY
00037 
00038 namespace absl {
00039 
00040 // -----------------------------------------------------------------------------
00041 // bad_any_cast
00042 // -----------------------------------------------------------------------------
00043 //
00044 // An `absl::bad_any_cast` type is an exception type that is thrown when
00045 // failing to successfully cast the return value of an `absl::any` object.
00046 //
00047 // Example:
00048 //
00049 //   auto a = absl::any(65);
00050 //   absl::any_cast<int>(a);         // 65
00051 //   try {
00052 //     absl::any_cast<char>(a);
00053 //   } catch(const absl::bad_any_cast& e) {
00054 //     std::cout << "Bad any cast: " << e.what() << '\n';
00055 //   }
00056 class bad_any_cast : public std::bad_cast {
00057  public:
00058   ~bad_any_cast() override;
00059   const char* what() const noexcept override;
00060 };
00061 
00062 namespace any_internal {
00063 
00064 [[noreturn]] void ThrowBadAnyCast();
00065 
00066 }  // namespace any_internal
00067 }  // namespace absl
00068 
00069 #endif  // ABSL_HAVE_STD_ANY
00070 
00071 #endif  // ABSL_TYPES_BAD_ANY_CAST_H_


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