abseil-cpp/absl/types/bad_variant_access.cc
Go to the documentation of this file.
1 // Copyright 2017 The Abseil Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #include "absl/types/bad_variant_access.h"
16 
17 #ifndef ABSL_USES_STD_VARIANT
18 
19 #include <cstdlib>
20 #include <stdexcept>
21 
22 #include "absl/base/config.h"
23 #include "absl/base/internal/raw_logging.h"
24 
25 namespace absl {
27 
29 // [variant.bad.access] //
31 
33 
34 const char* bad_variant_access::what() const noexcept {
35  return "Bad variant access";
36 }
37 
38 namespace variant_internal {
39 
41 #ifdef ABSL_HAVE_EXCEPTIONS
42  throw bad_variant_access();
43 #else
44  ABSL_RAW_LOG(FATAL, "Bad variant access");
45  abort(); // TODO(calabrese) Remove once RAW_LOG FATAL is noreturn.
46 #endif
47 }
48 
49 void Rethrow() {
50 #ifdef ABSL_HAVE_EXCEPTIONS
51  throw;
52 #else
54  "Internal error in absl::variant implementation. Attempted to "
55  "rethrow an exception when building with exceptions disabled.");
56  abort(); // TODO(calabrese) Remove once RAW_LOG FATAL is noreturn.
57 #endif
58 }
59 
60 } // namespace variant_internal
62 } // namespace absl
63 
64 #endif // ABSL_USES_STD_VARIANT
const
#define const
Definition: bloaty/third_party/zlib/zconf.h:230
absl::bad_variant_access
Definition: abseil-cpp/absl/types/bad_variant_access.h:64
absl::variant_internal::Rethrow
void Rethrow()
Definition: abseil-cpp/absl/types/bad_variant_access.cc:49
absl::bad_variant_access::~bad_variant_access
~bad_variant_access() override
absl::bad_variant_access::what
const char * what() const noexcept override
Definition: abseil-cpp/absl/types/bad_variant_access.cc:34
ABSL_NAMESPACE_END
#define ABSL_NAMESPACE_END
Definition: third_party/abseil-cpp/absl/base/config.h:171
ABSL_NAMESPACE_BEGIN
#define ABSL_NAMESPACE_BEGIN
Definition: third_party/abseil-cpp/absl/base/config.h:170
FATAL
#define FATAL(msg)
Definition: task.h:88
absl::variant_internal::ThrowBadVariantAccess
void ThrowBadVariantAccess()
Definition: abseil-cpp/absl/types/bad_variant_access.cc:40
absl
Definition: abseil-cpp/absl/algorithm/algorithm.h:31
ABSL_RAW_LOG
#define ABSL_RAW_LOG(severity,...)
Definition: abseil-cpp/absl/base/internal/raw_logging.h:44


grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:45