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 
16 
17 #ifndef ABSL_HAVE_STD_VARIANT
18 
19 #include <cstdlib>
20 #include <stdexcept>
21 
22 #include "absl/base/config.h"
24 
25 namespace absl {
26 
28 // [variant.bad.access] //
30 
32 
33 const char* bad_variant_access::what() const noexcept {
34  return "Bad variant access";
35 }
36 
37 namespace variant_internal {
38 
40 #ifdef ABSL_HAVE_EXCEPTIONS
41  throw bad_variant_access();
42 #else
43  ABSL_RAW_LOG(FATAL, "Bad variant access");
44  abort(); // TODO(calabrese) Remove once RAW_LOG FATAL is noreturn.
45 #endif
46 }
47 
48 void Rethrow() {
49 #ifdef ABSL_HAVE_EXCEPTIONS
50  throw;
51 #else
52  ABSL_RAW_LOG(FATAL,
53  "Internal error in absl::variant implementation. Attempted to "
54  "rethrow an exception when building with exceptions disabled.");
55  abort(); // TODO(calabrese) Remove once RAW_LOG FATAL is noreturn.
56 #endif
57 }
58 
59 } // namespace variant_internal
60 } // namespace absl
61 
62 #endif // ABSL_HAVE_STD_VARIANT
const char * what() const noexcept override
~bad_variant_access() override
#define ABSL_RAW_LOG(severity,...)
Definition: raw_logging.h:42
Definition: algorithm.h:29
bad_variant_access() noexcept=default


abseil_cpp
Author(s):
autogenerated on Mon Feb 28 2022 21:31:17