Changeset 0c327ce for libcfa/src/enum.cfa
- Timestamp:
- Jul 12, 2024, 3:30:06 PM (5 weeks ago)
- Branches:
- master
- Children:
- 76b507d
- Parents:
- 9c447e2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/enum.cfa
r9c447e2 r0c327ce 5 5 6 6 #pragma GCC visibility push(default) 7 8 forall( E | Serial( E ) ) { 9 E fromInt( unsigned i ) { 10 E upper = upperBound(); 11 E lower = lowerBound(); 12 // It is okay to overflow as overflow will be theoretically caught by the other bound 13 assert( i <= fromInstance(upper) && i >= fromInstance(lower) 14 && "Not a valid value"); 15 return fromInt_unsafe( i ); 16 } 17 18 E succ( E e ) { 19 E upper = upperBound(); 20 assert( (fromInstance(e) < fromInstance(upper)) 21 && "Calling succ() on the last" ); 22 return succ_unsafe(e); 23 } 24 25 E pred( E e ) { 26 E lower = lowerBound(); 27 assert( (fromInstance(e) > fromInstance(lower)) 28 && "Calling pred() on the first" ); 29 return pred_unsafe(e); 30 } 31 32 int Countof( __attribute__((unused)) E e ) { 33 E upper = upperBound(); 34 E lower = lowerBound(); 35 return fromInstance( upper ) + fromInstance( lower ) + 1; 36 } 37 } 7 38 8 39 int scmp( const void * str1, const void * str2 ) {
Note: See TracChangeset
for help on using the changeset viewer.