commit 116f2b84461f82d0943f165d2c9153dd65a5b526 parent 318e8201d570346624e7cae303503a84c1817be1 Author: Michael Savage <mikejsavage@gmail.com> Date: Wed Aug 30 18:03:29 +0100 Make things like min/max/etc constexpr Diffstat:
intrinsics.h | | | 16 | ++++++++-------- |
diff --git a/intrinsics.h b/intrinsics.h @@ -84,44 +84,44 @@ char ( &ArrayCountObj( const T ( & )[ N ] ) )[ N ]; #define gigabytes( gb ) ( megabytes( gb ) * size_t( 1024 ) ) template< typename T > -inline T min( T a, T b ) { +constexpr T min( T a, T b ) { return a < b ? a : b; } template< typename T > -inline T max( T a, T b ) { +constexpr T max( T a, T b ) { return a > b ? a : b; } template< typename T > -inline T max( T a, T b, T c, T d ) { +constexpr T max( T a, T b, T c, T d ) { return max( max( max( a, b ), c ), d ); } template< typename T > -inline T min( T a, T b, T c, T d ) { +constexpr T min( T a, T b, T c, T d ) { return min( min( min( a, b ), c ), d ); } template< typename T > -inline T abs( T x ) { +constexpr T abs( T x ) { return x > 0 ? x : -x; } template< typename T > -inline T clamp( T x, T lo, T hi ) { +constexpr T clamp( T x, T lo, T hi ) { if( x < lo ) return lo; if( x > hi ) return hi; return x; } template< typename T > -inline T saturate( T x ) { +constexpr T saturate( T x ) { return clamp( x, T( 0 ), T( 1 ) ); } template< typename T > -inline T clamp11( T x ) { +constexpr T clamp11( T x ) { return clamp( x, T( -1 ), T( 1 ) ); }