source: libcfa/src/enum.hfa@ 07e9df1

Last change on this file since 07e9df1 was 07e9df1, checked in by Peter A. Buhr <pabuhr@…>, 18 months ago

formatting

  • Property mode set to 100644
File size: 898 bytes
Line 
1#pragma once
2
3forall( E ) trait Bounded {
4 E lowerBound();
5 E upperBound();
6};
7
8forall( E | Bounded( E ) ) trait Serial {
9 unsigned fromInstance( E e );
10 E fromInt( unsigned int posn );
11 E succ( E e );
12 E pred( E e );
13};
14
15forall( E, T ) trait TypedEnum {
16 T valueE( E e );
17 char * labelE( E e );
18 unsigned int posE( E e );
19};
20
21forall( E, T | TypedEnum( E, T ) ) {
22 // comparison
23 int ?==?( E l, E r ); // true if l and r are same enumerators
24 int ?!=?( E l, E r ); // true if l and r are different enumerators
25 int ?!=?( E l, zero_t ); // true if l is not the first enumerator
26 int ?<?( E l, E r ); // true if l is an enuemerator before r
27 int ?<=?( E l, E r ); // true if l before or the same as r
28 int ?>?( E l, E r ); // true if l is an enuemrator after r
29 int ?>=?( E l, E r ); // true if l after or the same as r
30}
Note: See TracBrowser for help on using the repository browser.