bad_variant_access.cc
Go to the documentation of this file.
00001 // Copyright 2017 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 #include "absl/types/bad_variant_access.h"
00016 
00017 #ifndef ABSL_HAVE_STD_VARIANT
00018 
00019 #include <cstdlib>
00020 #include <stdexcept>
00021 
00022 #include "absl/base/config.h"
00023 #include "absl/base/internal/raw_logging.h"
00024 
00025 namespace absl {
00026 
00028 // [variant.bad.access] //
00030 
00031 bad_variant_access::~bad_variant_access() = default;
00032 
00033 const char* bad_variant_access::what() const noexcept {
00034   return "Bad variant access";
00035 }
00036 
00037 namespace variant_internal {
00038 
00039 void ThrowBadVariantAccess() {
00040 #ifdef ABSL_HAVE_EXCEPTIONS
00041   throw bad_variant_access();
00042 #else
00043   ABSL_RAW_LOG(FATAL, "Bad variant access");
00044   abort();  // TODO(calabrese) Remove once RAW_LOG FATAL is noreturn.
00045 #endif
00046 }
00047 
00048 void Rethrow() {
00049 #ifdef ABSL_HAVE_EXCEPTIONS
00050   throw;
00051 #else
00052   ABSL_RAW_LOG(FATAL,
00053                "Internal error in absl::variant implementation. Attempted to "
00054                "rethrow an exception when building with exceptions disabled.");
00055   abort();  // TODO(calabrese) Remove once RAW_LOG FATAL is noreturn.
00056 #endif
00057 }
00058 
00059 }  // namespace variant_internal
00060 }  // namespace absl
00061 
00062 #endif  // ABSL_HAVE_STD_VARIANT


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