…but I think the author meant “named arguments”, like we have in C#, Swift, and Objective-C.
int x = 5 <xor> 3; // x = 6
The basic trick was to notice that this is really parsed as: int x = ((5 < xor) > 3);
which you could implement with (roughly): struct XorType1 { ... } xor;
struct XorType2 {
int left;
XorType2(int left) : left(left) {}
int operator>(int right) const {
return left ^ right;
}
};
XorType2 operator<(int left, XorType1 const& ignored) {
return XorType2(left);
}
But I sat on this for a while and later discovered someone else had already come up with it :-/EDIT: Thanks commenter hawkice for fixing my XOR arithmetic!
kccqzy•1h ago
manwe150•56m ago
rwmj•24m ago