mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-29 16:40:39 +08:00
Make Throw a macro, for platforms missing definitions for std::*_error types.
This commit is contained in:
Vendored
+29
-27
@@ -622,83 +622,85 @@ namespace phmap {
|
|||||||
namespace base_internal {
|
namespace base_internal {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
template <typename T>
|
|
||||||
#ifdef PHMAP_HAVE_EXCEPTIONS
|
#ifdef PHMAP_HAVE_EXCEPTIONS
|
||||||
[[noreturn]] void Throw(const T& error) {
|
#define PHMAP_THROW_IMPL(e) throw e
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
[[noreturn]] void Throw(const T&) {
|
#define PHMAP_THROW_IMPL(e) std::abort()
|
||||||
std::abort();
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
static inline void ThrowStdLogicError(const std::string& what_arg) {
|
static inline void ThrowStdLogicError(const std::string& what_arg) {
|
||||||
Throw(std::logic_error(what_arg));
|
PHMAP_THROW_IMPL(std::logic_error(what_arg));
|
||||||
}
|
}
|
||||||
static inline void ThrowStdLogicError(const char* what_arg) {
|
static inline void ThrowStdLogicError(const char* what_arg) {
|
||||||
Throw(std::logic_error(what_arg));
|
PHMAP_THROW_IMPL(std::logic_error(what_arg));
|
||||||
}
|
}
|
||||||
static inline void ThrowStdInvalidArgument(const std::string& what_arg) {
|
static inline void ThrowStdInvalidArgument(const std::string& what_arg) {
|
||||||
Throw(std::invalid_argument(what_arg));
|
PHMAP_THROW_IMPL(std::invalid_argument(what_arg));
|
||||||
}
|
}
|
||||||
static inline void ThrowStdInvalidArgument(const char* what_arg) {
|
static inline void ThrowStdInvalidArgument(const char* what_arg) {
|
||||||
Throw(std::invalid_argument(what_arg));
|
PHMAP_THROW_IMPL(std::invalid_argument(what_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ThrowStdDomainError(const std::string& what_arg) {
|
static inline void ThrowStdDomainError(const std::string& what_arg) {
|
||||||
Throw(std::domain_error(what_arg));
|
PHMAP_THROW_IMPL(std::domain_error(what_arg));
|
||||||
}
|
}
|
||||||
static inline void ThrowStdDomainError(const char* what_arg) {
|
static inline void ThrowStdDomainError(const char* what_arg) {
|
||||||
Throw(std::domain_error(what_arg));
|
PHMAP_THROW_IMPL(std::domain_error(what_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ThrowStdLengthError(const std::string& what_arg) {
|
static inline void ThrowStdLengthError(const std::string& what_arg) {
|
||||||
Throw(std::length_error(what_arg));
|
PHMAP_THROW_IMPL(std::length_error(what_arg));
|
||||||
}
|
}
|
||||||
static inline void ThrowStdLengthError(const char* what_arg) {
|
static inline void ThrowStdLengthError(const char* what_arg) {
|
||||||
Throw(std::length_error(what_arg));
|
PHMAP_THROW_IMPL(std::length_error(what_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ThrowStdOutOfRange(const std::string& what_arg) {
|
static inline void ThrowStdOutOfRange(const std::string& what_arg) {
|
||||||
Throw(std::out_of_range(what_arg));
|
PHMAP_THROW_IMPL(std::out_of_range(what_arg));
|
||||||
}
|
}
|
||||||
static inline void ThrowStdOutOfRange(const char* what_arg) {
|
static inline void ThrowStdOutOfRange(const char* what_arg) {
|
||||||
Throw(std::out_of_range(what_arg));
|
PHMAP_THROW_IMPL(std::out_of_range(what_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ThrowStdRuntimeError(const std::string& what_arg) {
|
static inline void ThrowStdRuntimeError(const std::string& what_arg) {
|
||||||
Throw(std::runtime_error(what_arg));
|
PHMAP_THROW_IMPL(std::runtime_error(what_arg));
|
||||||
}
|
}
|
||||||
static inline void ThrowStdRuntimeError(const char* what_arg) {
|
static inline void ThrowStdRuntimeError(const char* what_arg) {
|
||||||
Throw(std::runtime_error(what_arg));
|
PHMAP_THROW_IMPL(std::runtime_error(what_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ThrowStdRangeError(const std::string& what_arg) {
|
static inline void ThrowStdRangeError(const std::string& what_arg) {
|
||||||
Throw(std::range_error(what_arg));
|
PHMAP_THROW_IMPL(std::range_error(what_arg));
|
||||||
}
|
}
|
||||||
static inline void ThrowStdRangeError(const char* what_arg) {
|
static inline void ThrowStdRangeError(const char* what_arg) {
|
||||||
Throw(std::range_error(what_arg));
|
PHMAP_THROW_IMPL(std::range_error(what_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ThrowStdOverflowError(const std::string& what_arg) {
|
static inline void ThrowStdOverflowError(const std::string& what_arg) {
|
||||||
Throw(std::overflow_error(what_arg));
|
PHMAP_THROW_IMPL(std::overflow_error(what_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ThrowStdOverflowError(const char* what_arg) {
|
static inline void ThrowStdOverflowError(const char* what_arg) {
|
||||||
Throw(std::overflow_error(what_arg));
|
PHMAP_THROW_IMPL(std::overflow_error(what_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ThrowStdUnderflowError(const std::string& what_arg) {
|
static inline void ThrowStdUnderflowError(const std::string& what_arg) {
|
||||||
Throw(std::underflow_error(what_arg));
|
PHMAP_THROW_IMPL(std::underflow_error(what_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ThrowStdUnderflowError(const char* what_arg) {
|
static inline void ThrowStdUnderflowError(const char* what_arg) {
|
||||||
Throw(std::underflow_error(what_arg));
|
PHMAP_THROW_IMPL(std::underflow_error(what_arg));
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ThrowStdBadFunctionCall() { Throw(std::bad_function_call()); }
|
static inline void ThrowStdBadFunctionCall() {
|
||||||
|
PHMAP_THROW_IMPL(std::bad_function_call());
|
||||||
|
}
|
||||||
|
|
||||||
static inline void ThrowStdBadAlloc() { Throw(std::bad_alloc()); }
|
static inline void ThrowStdBadAlloc() {
|
||||||
|
PHMAP_THROW_IMPL(std::bad_alloc());
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace base_internal
|
} // namespace base_internal
|
||||||
} // namespace phmap
|
} // namespace phmap
|
||||||
|
|||||||
Reference in New Issue
Block a user