Am 21.10.2016 um 23:43 schrieb Rahman Salim Zengin:
Hi,
The code in question is a simple chained comparison implementation. It works with any type If relational operators for that type is defined.
https://github.com/rszengin/chain
May some people find it useful?
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Considering that the actual use-cases are things like "x < y <= z" I'd rather think about this as a set of ternary operators. They would be: < < < <= <= < <= <=
= >
= = >=
Things like x < y > z wouldn't make that sense from a logical point of view - I'd just not allow them. I think the right approach would be something like that: x < ternary(y) < z That way you can limit the amount of operators available, so what is writtern there actually makes sense. I'd actually return bool for the ternary example, but you have one with five values. I wouldn't do it, but you could let the ternary operation return a bool-convertible proxy object, so you could chain up five: 0.4 < ternary(a <= ternary(b) <= c) < 0.6 But I'm not sure there are actually that much use cases; I'd think the main would be, to check if y is in the right range. And then - to top it off - we could add comparisions with a tolerance (should work according to the operator precedence rules): x == y +- ternary(z) and it could be made a relative tolerance. x == y +- ~ ternary(z) Well - those are basically the useful ternary operations I can think of.