forked from grantrostig/cpp_by_example
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathmain.cpp
More file actions
105 lines (97 loc) · 2.05 KB
/
main.cpp
File metadata and controls
105 lines (97 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <iostream>
using namespace std;
enum class field_completion: int {
up,
down
};
enum class intra_field: int {
left,
right
};
// enum class fields : /* intra_field,*/ field_completion {
// };
enum class fields_u {
intra_field,
field_completion
};
//=======================================
// https://stackoverflow.com/questions/18344646/combine-enums-c
//=======================================
enum OperationType {
Comparison = 0x100,
Arithmetic = 0x200
};
enum ComparisonType
{
LT = Comparison, // "<"
GT, // ">"
EQ, // "=="
LTEQ, // "<="
GTEQ, // ">="
NEQ // "!="
};
enum ArithmeticType
{
ADD = Arithmetic, // "+"
SUB, // "-"
MUL, // "*"
DIV, // "/"
MOD // "%"
};
// constexpr OperationType getOperationType(unsigned value) {return value & 0xFF00;} // TODO compile error
constexpr OperationType getOperationType(unsigned value) { auto v = value & 0xFF00; return (OperatorType)v;} // TODO compile error
//=======================================
//enum Comparison
//{
// LT, // "<"
// GT, // ">"
// EQ, // "=="
// LTEQ, // "<="
// GTEQ, // ">="
// NEQ, // "!="
// LastComparison
//};
//enum Logical
//{
// AND = LastComparison,
// OR,
// XOR,
// LastLogical
//};
//=======================================
enum class Comparisonc : int
{
LT, // "<"
GT, // ">"
EQ, // "=="
LTEQ, // "<="
GTEQ, // ">="
NEQ, // "!="
LastComparison
};
enum class Logicalc : int
{
AND = (int)Comparisonc::LastComparison,
OR,
XOR,
LastLogical
};
struct unionc {
union {
Comparisonc a;
Logicalc b;
};
};
//==========================================
int main()
{
// if ( LT == XOR ) {}
if ( (int)Comparisonc::LT == (int)Logicalc::XOR ) {}
switch ( (int) Comparisonc::LT ) {
case (int) Comparisonc::LT :
case (int) Logicalc:: XOR :
break;
}
cout << "###" << endl;
return 0;
}