mirror of
https://github.com/catchorg/Catch2.git
synced 2025-10-16 23:25:39 +02:00
Introduce stubs for throwing specific exception types
This allows us to move <stdexcept> out of the common path, and replace it with just <exception>. The difference between these two headers is ~13k lines after preprocessing on libstdc++ (16k vs 3k) and ~17k lines for MS's STL(33k vs 16k). Note that this is only beneficial if no other stdlib header we use includes <stdexcept>. AFAIK this is true for the newest MS's STL, but I have no idea of the applicability for libstdc++ and libc++.
This commit is contained in:
@@ -7,6 +7,9 @@
|
||||
|
||||
#include "catch_enforce.h"
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
|
||||
namespace Catch {
|
||||
#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER)
|
||||
[[noreturn]]
|
||||
@@ -16,4 +19,22 @@ namespace Catch {
|
||||
std::terminate();
|
||||
}
|
||||
#endif
|
||||
|
||||
[[noreturn]]
|
||||
void throw_logic_error(std::string const& msg) {
|
||||
throw_exception(std::logic_error(msg));
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
void throw_domain_error(std::string const& msg) {
|
||||
throw_exception(std::domain_error(msg));
|
||||
}
|
||||
|
||||
[[noreturn]]
|
||||
void throw_runtime_error(std::string const& msg) {
|
||||
throw_exception(std::runtime_error(msg));
|
||||
}
|
||||
|
||||
|
||||
|
||||
} // namespace Catch;
|
||||
|
Reference in New Issue
Block a user