always use fmt :: internal::do_throw(x)

simplify
This commit is contained in:
dbj 2019-11-13 08:29:40 +01:00 committed by GitHub
parent 8d5f9d6d40
commit f756233686
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -80,39 +80,30 @@ FMT_BEGIN_NAMESPACE
}
FMT_END_NAMESPACE
#ifndef FMT_THROW
# if FMT_EXCEPTIONS
# if FMT_MSC_VER
//TODO: why is this only for MSVC builds?
FMT_BEGIN_NAMESPACE
namespace internal {
#define FMT_FAST_FAIL 1 /*TODO: remove before relase, here for testing purposes */
#if FMT_FAST_FAIL
template <typename Exception> [[noreturn]] inline void do_throw(const Exception& x) {
terror(x.what());
}
#else
template <typename Exception> inline void do_throw(const Exception& x) {
// Silence unreachable code warnings in MSVC because these are nearly
// impossible to fix in a generic code.
volatile bool b = true;
if (b) throw x;
// terror == terminating error
[[noreturn]] inline void terror(const char msg_[BUFSIZ]) {
::puts("\n\n\nFast exit on {fmt} error with message: ");
::puts(msg_);
::perror("\nPOSIX error message: ");
std::exit(EXIT_FAILURE);
}
namespace internal {
template <typename Exception>
#ifndef FMT_EXCEPTIONS
[[noreturn]]
#endif
inline void do_throw(const Exception& x) {
#if FMT_EXCEPTIONS
throw x;
#else
terror(x.what());
#endif
}
} // namespace internal
FMT_END_NAMESPACE
//TODO: why is do_throw() only for MSVC builds?
# define FMT_THROW(x) fmt :: internal::do_throw(x)
# else
# define FMT_THROW(x) throw x
# endif
# else
# define FMT_THROW(x) \
do { \
fmt :: terror(x.what()) \
} while (false)
# endif
#endif
#define FMT_THROW(x) fmt :: internal::do_throw(x)
#ifndef FMT_USE_USER_DEFINED_LITERALS
// For Intel and NVIDIA compilers both they and the system gcc/msc support UDLs.