mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-04 09:01:50 +01:00 
			
		
		
		
	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++.
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
/*
 | 
						|
 *  Created by Martin on 03/09/2018.
 | 
						|
 *
 | 
						|
 *  Distributed under the Boost Software License, Version 1.0. (See accompanying
 | 
						|
 *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
 | 
						|
 */
 | 
						|
 | 
						|
#include "catch_enforce.h"
 | 
						|
 | 
						|
#include <stdexcept>
 | 
						|
 | 
						|
 | 
						|
namespace Catch {
 | 
						|
#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER)
 | 
						|
    [[noreturn]]
 | 
						|
    void throw_exception(std::exception const& e) {
 | 
						|
        Catch::cerr() << "Catch will terminate because it needed to throw an exception.\n"
 | 
						|
                      << "The message was: " << e.what() << '\n';
 | 
						|
        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;
 |