- Timestamp:
- Aug 29, 2024, 2:38:39 PM (4 months ago)
- Branches:
- master
- Children:
- 9bb6c5f
- Parents:
- 960665c (diff), b965774 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/common.hfa
r960665c rad47ec4 10 10 // Created On : Wed Jul 11 17:54:36 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Aug 14 17:01:47 202313 // Update Count : 3812 // Last Modified On : Sat Aug 24 08:01:36 2024 13 // Update Count : 43 14 14 // 15 15 … … 66 66 67 67 static inline __attribute__((always_inline)) { 68 forall( T | { int ?<?( T, T ); } )69 T min( T v1, T v2 ) { return v1 < v2 ? v1 : v2; }70 71 forall( T, Ts... | { T min( T, T ); T min( T, T, Ts ); } )72 T min( T v1, T v2, T v3, Ts vs ) { return min( min( v1, v2 ), v3, vs ); }73 74 forall( T | { int ?>?( T, T ); } )75 T max( T v1, T v2 ) { return v1 > v2 ? v1 : v2; }76 77 forall( T, Ts... | { T max( T, T ); T max( T, T, Ts ); } )78 T max( T v1, T v2, T v3, Ts vs ) { return max( max( v1, v2 ), v3, vs ); }79 80 forall( T | { T min( T, T ); T max( T, T ); } )81 T clamp( T value, T min_val, T max_val ) { return max( min_val, min( value, max_val ) ); }82 83 forall( T )84 void swap( T & v1, T & v2 ) { T temp = v1; v1 = v2; v2 = temp; }85 86 68 // Specializations 87 69 char min( char v1, char v2 ) { return v1 < v2 ? v1 : v2; } … … 100 82 long long int max( long long int v1, long long int v2 ) { return v1 > v2 ? v1 : v2; } 101 83 unsigned long long int max( unsigned long long int v1, unsigned long long int v2 ) { return v1 > v2 ? v1 : v2; } 84 85 // Polymorphic 86 forall( T | { int ?<?( T, T ); } ) 87 T min( T v1, T v2 ) { return v1 < v2 ? v1 : v2; } 88 89 forall( T, Ts ... | { T min( T, T ); T min( Ts ); } ) 90 T min( T arg, Ts args ) { return min( arg, min( args ) ); } 91 92 forall( T | { int ?>?( T, T ); } ) 93 T max( T v1, T v2 ) { return v1 > v2 ? v1 : v2; } 94 95 forall( T, Ts ... | { T max( T, T ); T max( Ts ); } ) 96 T max( T arg, Ts args ) { return max( arg, max( args ) ); } 97 98 forall( T | { T min( T, T ); T max( T, T ); } ) 99 T clamp( T value, T min_val, T max_val ) { return max( min_val, min( value, max_val ) ); } 100 101 forall( T ) 102 void swap( T & v1, T & v2 ) { T temp = v1; v1 = v2; v2 = temp; } 102 103 } // distribution 103 104
Note: See TracChangeset
for help on using the changeset viewer.