Topic: axioms in LessThanComparable
Author: restor <akrzemi1@interia.pl>
Date: Mon, 2 Jul 2007 11:29:58 CST Raw View
In the web I found the following definition of LessThanComparable
concept that was intended to show how axioms work:
concept LessThanComparable<typename T> {
bool operator<(T, T);
axiom Irreflexivity(T x) { !(x < x); }
axiom Asymmetry(T x, T y) {
if (x < y) !(y < x);
}
axiom Transitivity(T x, T y, T z) {
if (x < y && y < z) x < z;
}
}
Now, in N2322 the definition of LessThanComparable doesn't use axioms,
but instead provides a human-readable text "operator< is a strict weak
ordering relation".
Is it intentional?
Thanks,
&rzej
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Douglas Gregor <doug.gregor@gmail.com>
Date: Mon, 2 Jul 2007 15:09:58 CST Raw View
On Jul 2, 1:29 pm, restor <akrze...@interia.pl> wrote:
> In the web I found the following definition of LessThanComparable
> concept that was intended to show how axioms work:
[snip example]
> Now, in N2322 the definition of LessThanComparable doesn't use axioms,
> but instead provides a human-readable text "operator< is a strict weak
> ordering relation".
>
> Is it intentional?
Yes. Those axioms depend on the left- and right-hand types being
exactly the same ('T'). The LessThanComparable in N2322 has different
left- and right-hand types (T and U), so we can't really express the
axioms.
We have considered adding a concept StrictWeakOrdering<T> that refines
LessThanComparable<T, T> and contains those axioms.
- Doug
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]