|
|
|||
File indexing completed on 2025-12-16 09:40:42
0001 // 0002 // Copyright 2017 The Abseil Authors. 0003 // 0004 // Licensed under the Apache License, Version 2.0 (the "License"); 0005 // you may not use this file except in compliance with the License. 0006 // You may obtain a copy of the License at 0007 // 0008 // https://www.apache.org/licenses/LICENSE-2.0 0009 // 0010 // Unless required by applicable law or agreed to in writing, software 0011 // distributed under the License is distributed on an "AS IS" BASIS, 0012 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 0013 // See the License for the specific language governing permissions and 0014 // limitations under the License. 0015 // 0016 0017 #ifndef ABSL_BASE_INTERNAL_THROW_DELEGATE_H_ 0018 #define ABSL_BASE_INTERNAL_THROW_DELEGATE_H_ 0019 0020 #include <string> 0021 0022 #include "absl/base/config.h" 0023 0024 namespace absl { 0025 ABSL_NAMESPACE_BEGIN 0026 namespace base_internal { 0027 0028 // Helper functions that allow throwing exceptions consistently from anywhere. 0029 // The main use case is for header-based libraries (eg templates), as they will 0030 // be built by many different targets with their own compiler options. 0031 // In particular, this will allow a safe way to throw exceptions even if the 0032 // caller is compiled with -fno-exceptions. This is intended for implementing 0033 // things like map<>::at(), which the standard documents as throwing an 0034 // exception on error. 0035 // 0036 // Using other techniques like #if tricks could lead to ODR violations. 0037 // 0038 // You shouldn't use it unless you're writing code that you know will be built 0039 // both with and without exceptions and you need to conform to an interface 0040 // that uses exceptions. 0041 0042 [[noreturn]] void ThrowStdLogicError(const std::string& what_arg); 0043 [[noreturn]] void ThrowStdLogicError(const char* what_arg); 0044 [[noreturn]] void ThrowStdInvalidArgument(const std::string& what_arg); 0045 [[noreturn]] void ThrowStdInvalidArgument(const char* what_arg); 0046 [[noreturn]] void ThrowStdDomainError(const std::string& what_arg); 0047 [[noreturn]] void ThrowStdDomainError(const char* what_arg); 0048 [[noreturn]] void ThrowStdLengthError(const std::string& what_arg); 0049 [[noreturn]] void ThrowStdLengthError(const char* what_arg); 0050 [[noreturn]] void ThrowStdOutOfRange(const std::string& what_arg); 0051 [[noreturn]] void ThrowStdOutOfRange(const char* what_arg); 0052 [[noreturn]] void ThrowStdRuntimeError(const std::string& what_arg); 0053 [[noreturn]] void ThrowStdRuntimeError(const char* what_arg); 0054 [[noreturn]] void ThrowStdRangeError(const std::string& what_arg); 0055 [[noreturn]] void ThrowStdRangeError(const char* what_arg); 0056 [[noreturn]] void ThrowStdOverflowError(const std::string& what_arg); 0057 [[noreturn]] void ThrowStdOverflowError(const char* what_arg); 0058 [[noreturn]] void ThrowStdUnderflowError(const std::string& what_arg); 0059 [[noreturn]] void ThrowStdUnderflowError(const char* what_arg); 0060 0061 [[noreturn]] void ThrowStdBadFunctionCall(); 0062 [[noreturn]] void ThrowStdBadAlloc(); 0063 0064 // ThrowStdBadArrayNewLength() cannot be consistently supported because 0065 // std::bad_array_new_length is missing in libstdc++ until 4.9.0. 0066 // https://gcc.gnu.org/onlinedocs/gcc-4.8.3/libstdc++/api/a01379_source.html 0067 // https://gcc.gnu.org/onlinedocs/gcc-4.9.0/libstdc++/api/a01327_source.html 0068 // libcxx (as of 3.2) and msvc (as of 2015) both have it. 0069 // [[noreturn]] void ThrowStdBadArrayNewLength(); 0070 0071 } // namespace base_internal 0072 ABSL_NAMESPACE_END 0073 } // namespace absl 0074 0075 #endif // ABSL_BASE_INTERNAL_THROW_DELEGATE_H_
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|