Skip to content

Commit 7340b4f

Browse files
Merge pull request #13 from mcpplibs/feat-add-more-operations
Refactor tests and add unary/binary operations with error handling
2 parents 99f3f2a + db906c3 commit 7340b4f

File tree

5 files changed

+1410
-0
lines changed

5 files changed

+1410
-0
lines changed

src/operations/impl.cppm

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,70 @@ import mcpplibs.primitives.operations.traits;
44

55
export namespace mcpplibs::primitives::operations {
66

7+
// Unary operations
8+
struct Increment {};
9+
struct Decrement {};
10+
struct BitwiseNot {};
11+
struct UnaryPlus {};
12+
struct UnaryMinus {};
13+
14+
// Binary operations
715
struct Addition {};
816
struct Subtraction {};
917
struct Multiplication {};
1018
struct Division {};
19+
struct Modulus {};
20+
struct LeftShift {};
21+
struct RightShift {};
22+
struct BitwiseAnd {};
23+
struct BitwiseOr {};
24+
struct BitwiseXor {};
25+
26+
// Comparison operations
1127
struct Equal {};
1228
struct NotEqual {};
1329
struct ThreeWayCompare {};
1430

31+
template <> struct traits<Increment> {
32+
using op_tag = Increment;
33+
34+
static constexpr bool enabled = true;
35+
static constexpr auto arity = dimension::unary;
36+
static constexpr auto capability_mask = capability::arithmetic;
37+
};
38+
39+
template <> struct traits<Decrement> {
40+
using op_tag = Decrement;
41+
42+
static constexpr bool enabled = true;
43+
static constexpr auto arity = dimension::unary;
44+
static constexpr auto capability_mask = capability::arithmetic;
45+
};
46+
47+
template <> struct traits<BitwiseNot> {
48+
using op_tag = BitwiseNot;
49+
50+
static constexpr bool enabled = true;
51+
static constexpr auto arity = dimension::unary;
52+
static constexpr auto capability_mask = capability::bitwise;
53+
};
54+
55+
template <> struct traits<UnaryPlus> {
56+
using op_tag = UnaryPlus;
57+
58+
static constexpr bool enabled = true;
59+
static constexpr auto arity = dimension::unary;
60+
static constexpr auto capability_mask = capability::arithmetic;
61+
};
62+
63+
template <> struct traits<UnaryMinus> {
64+
using op_tag = UnaryMinus;
65+
66+
static constexpr bool enabled = true;
67+
static constexpr auto arity = dimension::unary;
68+
static constexpr auto capability_mask = capability::arithmetic;
69+
};
70+
1571
template <> struct traits<Addition> {
1672
using op_tag = Addition;
1773

@@ -44,6 +100,54 @@ template <> struct traits<Division> {
44100
static constexpr auto capability_mask = capability::arithmetic;
45101
};
46102

103+
template <> struct traits<Modulus> {
104+
using op_tag = Modulus;
105+
106+
static constexpr bool enabled = true;
107+
static constexpr auto arity = dimension::binary;
108+
static constexpr auto capability_mask = capability::arithmetic;
109+
};
110+
111+
template <> struct traits<LeftShift> {
112+
using op_tag = LeftShift;
113+
114+
static constexpr bool enabled = true;
115+
static constexpr auto arity = dimension::binary;
116+
static constexpr auto capability_mask = capability::bitwise;
117+
};
118+
119+
template <> struct traits<RightShift> {
120+
using op_tag = RightShift;
121+
122+
static constexpr bool enabled = true;
123+
static constexpr auto arity = dimension::binary;
124+
static constexpr auto capability_mask = capability::bitwise;
125+
};
126+
127+
template <> struct traits<BitwiseAnd> {
128+
using op_tag = BitwiseAnd;
129+
130+
static constexpr bool enabled = true;
131+
static constexpr auto arity = dimension::binary;
132+
static constexpr auto capability_mask = capability::bitwise;
133+
};
134+
135+
template <> struct traits<BitwiseOr> {
136+
using op_tag = BitwiseOr;
137+
138+
static constexpr bool enabled = true;
139+
static constexpr auto arity = dimension::binary;
140+
static constexpr auto capability_mask = capability::bitwise;
141+
};
142+
143+
template <> struct traits<BitwiseXor> {
144+
using op_tag = BitwiseXor;
145+
146+
static constexpr bool enabled = true;
147+
static constexpr auto arity = dimension::binary;
148+
static constexpr auto capability_mask = capability::bitwise;
149+
};
150+
47151
template <> struct traits<Equal> {
48152
using op_tag = Equal;
49153

0 commit comments

Comments
 (0)