
On Sat, May 28, 2011 at 4:16 PM, Steven Watanabe <watanabesj@gmail.com>wrote:
AMDG
On 05/28/2011 12:42 PM, Pyry Jahkola wrote:
On 2011-05-28 21:59:57 +0300, Matt Calabrese said:
On Sat, May 28, 2011 at 2:55 PM, Steven Watanabe <watanabesj@gmail.com>wrote:
I don't have the concepts proposal handy, but doesn't LessThanComparable have an axiom that requires that (a < b) is equivalent to (b > a)?
Yes.
axiom Consistency(T a, T b) { (a > b) == (b < a); (a <= b) == !(b < a); (a >= b) == !(a < b); }
For what it's worth, e.g. NaN's are an exception to that rule...
It's not an exception. The axiom only applies to LessThanComparable types. Technically, double isn't LessThanComparable, because it violates this rule.
Sorry, this is sort of on a tangent, but this is, imo, one of the problems with what would have been 0x concepts. According to N2914, LessThanComparable is an auto concept, meaning that as long as a type has an operation that matches the pseudo-signature bool operator< ( T const&, T const& ), then that type is LessThanComparable, even though the compiler can't really "check" the axioms. So in hypothetical 0x concept-land, checking if double models LessThanComparable would yield true. Most auto concepts that have axioms are scary. -- -Matt Calabrese