Boost logo

Boost :

Subject: Re: [boost] [type_erasure] default implementation of concept signatures
From: Pyry Jahkola (pyry.jahkola_at_[hidden])
Date: 2011-05-28 15:42:03


On 2011-05-28 21:59:57 +0300, Matt Calabrese said:

> On Sat, May 28, 2011 at 2:55 PM, Steven Watanabe <watanabesj_at_[hidden]>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...

#include <limits>
#include <iostream>
#define PRINT(x) do { std::cout << #x ": " << (x) << std::endl; } while(0)
int main() {
    double one = 1;
    double nan = std::numeric_limits<double>::quiet_NaN();
    PRINT(one == nan); // false
    PRINT(one != nan); // true
    PRINT(one < nan); // false
    PRINT(one > nan); // false
    PRINT(one <= nan); // false
    PRINT(one >= nan); // false
}

-- 
Pyry Jahkola (a.k.a. pyrtsa)

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk