算子<与严格弱序如何定义operator<在n-tuple上(例如,在3-tuple上),以便它满足严格弱序概念?我知道Boost库具有定义正确的tuple类。operator<但出于某些原因我不能用它。
3 回答
人到中年有点甜
TA贡献1895条经验 获得超7个赞
if (a1 < b1) return true;if (b1 < a1) return false;// a1==b1: continue with element 2if (a2 < b2) return true;if (b2 < a2) return false;// a2 == b2: continue with element 3if (a3 < b3) return true;return false; // early out
while (i<count-1 && !(a[i] < a[i+1]) && !(a[i+1] < a[i]) ++i;return i < count-1 && a[i] < a[i+1];
operator<
if (a1 != b1) return a1 < b1;if (a2 != b2) return a2 < b2;...
忽然笑
TA贡献1806条经验 获得超5个赞
严格弱序
如果f(x,y)和f(y,x)都是假的,则两个对象x和y是等价的。注意,对象总是(通过非自反性不变式)与自身等效。
X a;X b;Condition: Test: Resulta is equivalent to b: a < b falsea is equivalent to b b < a falsea is less than b a < b truea is less than b b < a falseb is less than a a < b falseb is less than a b < a true
- 3 回答
- 0 关注
- 550 浏览
添加回答
举报
0/150
提交
取消