Back to home page

EIC code displayed by LXR

 
 

    


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_any_cast.h
0017 // -----------------------------------------------------------------------------
0018 //
0019 // This header file defines the `absl::bad_any_cast` type.
0020 
0021 #ifndef ABSL_TYPES_BAD_ANY_CAST_H_
0022 #define ABSL_TYPES_BAD_ANY_CAST_H_
0023 
0024 #include <typeinfo>
0025 
0026 #include "absl/base/config.h"
0027 
0028 #ifdef ABSL_USES_STD_ANY
0029 
0030 #include <any>
0031 
0032 namespace absl {
0033 ABSL_NAMESPACE_BEGIN
0034 using std::bad_any_cast;
0035 ABSL_NAMESPACE_END
0036 }  // namespace absl
0037 
0038 #else  // ABSL_USES_STD_ANY
0039 
0040 namespace absl {
0041 ABSL_NAMESPACE_BEGIN
0042 
0043 // -----------------------------------------------------------------------------
0044 // bad_any_cast
0045 // -----------------------------------------------------------------------------
0046 //
0047 // An `absl::bad_any_cast` type is an exception type that is thrown when
0048 // failing to successfully cast the return value of an `absl::any` object.
0049 //
0050 // Example:
0051 //
0052 //   auto a = absl::any(65);
0053 //   absl::any_cast<int>(a);         // 65
0054 //   try {
0055 //     absl::any_cast<char>(a);
0056 //   } catch(const absl::bad_any_cast& e) {
0057 //     std::cout << "Bad any cast: " << e.what() << '\n';
0058 //   }
0059 class bad_any_cast : public std::bad_cast {
0060  public:
0061   ~bad_any_cast() override;
0062   const char* what() const noexcept override;
0063 };
0064 
0065 namespace any_internal {
0066 
0067 [[noreturn]] void ThrowBadAnyCast();
0068 
0069 }  // namespace any_internal
0070 ABSL_NAMESPACE_END
0071 }  // namespace absl
0072 
0073 #endif  // ABSL_USES_STD_ANY
0074 
0075 #endif  // ABSL_TYPES_BAD_ANY_CAST_H_