mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Move nextafter polyfill to polyfills.hpp
This commit is contained in:
		| @@ -31,4 +31,12 @@ namespace Catch { | ||||
|     } | ||||
| #endif | ||||
|  | ||||
| #if !defined( CATCH_CONFIG_GLOBAL_NEXTAFTER ) | ||||
|     float nextafter( float x, float y ) { return std::nextafter( x, y ); } | ||||
|     double nextafter( double x, double y ) { return std::nextafter( x, y ); } | ||||
| #else | ||||
|     float nextafter( float x, float y ) { return ::nextafterf( x, y ); } | ||||
|     double nextafter( double x, double y ) { return ::nextafter( x, y ); } | ||||
| #endif | ||||
|  | ||||
| } // end namespace Catch | ||||
|   | ||||
| @@ -9,8 +9,13 @@ | ||||
| #define CATCH_POLYFILLS_HPP_INCLUDED | ||||
|  | ||||
| namespace Catch { | ||||
|  | ||||
|     bool isnan(float f); | ||||
|     bool isnan(double d); | ||||
|  | ||||
|     float nextafter(float x, float y); | ||||
|     double nextafter(double x, double y); | ||||
|  | ||||
| } | ||||
|  | ||||
| #endif // CATCH_POLYFILLS_HPP_INCLUDED | ||||
|   | ||||
| @@ -38,26 +38,11 @@ namespace { | ||||
|         return ulpDist <= maxUlpDiff; | ||||
|     } | ||||
|  | ||||
| #if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) | ||||
|  | ||||
|     float nextafter(float x, float y) { | ||||
|         return ::nextafterf(x, y); | ||||
|     } | ||||
|  | ||||
|     double nextafter(double x, double y) { | ||||
|         return ::nextafter(x, y); | ||||
|     } | ||||
|  | ||||
| #endif // ^^^ CATCH_CONFIG_GLOBAL_NEXTAFTER ^^^ | ||||
|  | ||||
| template <typename FP> | ||||
| FP step(FP start, FP direction, uint64_t steps) { | ||||
|     for (uint64_t i = 0; i < steps; ++i) { | ||||
| #if defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) | ||||
|         start = Catch::nextafter(start, direction); | ||||
| #else | ||||
|         start = std::nextafter(start, direction); | ||||
| #endif | ||||
|     } | ||||
|     return start; | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský