always use fmt :: internal::do_throw(x)
simplify
This commit is contained in:
parent
8d5f9d6d40
commit
f756233686
@ -80,39 +80,30 @@ FMT_BEGIN_NAMESPACE
|
|||||||
}
|
}
|
||||||
FMT_END_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
|
FMT_BEGIN_NAMESPACE
|
||||||
namespace internal {
|
// terror == terminating error
|
||||||
#define FMT_FAST_FAIL 1 /*TODO: remove before relase, here for testing purposes */
|
[[noreturn]] inline void terror(const char msg_[BUFSIZ]) {
|
||||||
#if FMT_FAST_FAIL
|
::puts("\n\n\nFast exit on {fmt} error with message: ");
|
||||||
template <typename Exception> [[noreturn]] inline void do_throw(const Exception& x) {
|
::puts(msg_);
|
||||||
terror(x.what());
|
::perror("\nPOSIX error message: ");
|
||||||
}
|
std::exit(EXIT_FAILURE);
|
||||||
#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;
|
|
||||||
}
|
}
|
||||||
|
namespace internal {
|
||||||
|
template <typename Exception>
|
||||||
|
#ifndef FMT_EXCEPTIONS
|
||||||
|
[[noreturn]]
|
||||||
#endif
|
#endif
|
||||||
|
inline void do_throw(const Exception& x) {
|
||||||
|
#if FMT_EXCEPTIONS
|
||||||
|
throw x;
|
||||||
|
#else
|
||||||
|
terror(x.what());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
} // namespace internal
|
} // namespace internal
|
||||||
FMT_END_NAMESPACE
|
FMT_END_NAMESPACE
|
||||||
//TODO: why is do_throw() only for MSVC builds?
|
|
||||||
# define FMT_THROW(x) fmt :: internal::do_throw(x)
|
#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
|
|
||||||
|
|
||||||
#ifndef FMT_USE_USER_DEFINED_LITERALS
|
#ifndef FMT_USE_USER_DEFINED_LITERALS
|
||||||
// For Intel and NVIDIA compilers both they and the system gcc/msc support UDLs.
|
// For Intel and NVIDIA compilers both they and the system gcc/msc support UDLs.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user