experimental fix for #307
This commit is contained in:
parent
debba6f769
commit
e61eb01942
2 changed files with 27 additions and 12 deletions
|
|
@ -50,6 +50,7 @@
|
|||
#define LUMIERA_P_H
|
||||
|
||||
|
||||
#include "lib/error.hpp"
|
||||
#include <tr1/memory>
|
||||
|
||||
|
||||
|
|
@ -107,19 +108,19 @@ namespace lumiera {
|
|||
|
||||
template<typename _O_>
|
||||
friend inline bool
|
||||
operator< (P const& p, P<_O_> const& q) { return (p && q) && (*p < *q); } ////TICKET #307 : problem with equality test in associative containers, where equal(a,b) := !(a < b) && !(b < a)
|
||||
operator< (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p < *q; } ///< @note deliberately not allowing comparison on NIL ////TICKET #307 : problem with equality test in associative containers, where equal(a,b) := !(a < b) && !(b < a)
|
||||
|
||||
template<typename _O_>
|
||||
friend inline bool
|
||||
operator> (P const& p, P<_O_> const& q) { return (p && q) && (*q < *p); }
|
||||
operator> (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *q < *p; }
|
||||
|
||||
template<typename _O_>
|
||||
friend inline bool
|
||||
operator<= (P const& p, P<_O_> const& q) { return (p && q)? (*p <= *q) : (!p && !q); }
|
||||
operator<= (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p <= *q;}
|
||||
|
||||
template<typename _O_>
|
||||
friend inline bool
|
||||
operator>= (P const& p, P<_O_> const& q) { return (p && q)? (*p >= *q) : (!p && !q); }
|
||||
operator>= (P const& p, P<_O_> const& q) { REQUIRE (p && q); return *p >= *q;}
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
|
||||
#include "lib/test/run.hpp"
|
||||
#include "lib/test/test-helper.hpp"
|
||||
#include "lib/util.hpp"
|
||||
|
||||
#include "lib/p.hpp"
|
||||
|
|
@ -37,6 +38,8 @@ namespace asset {
|
|||
using lumiera::P;
|
||||
using std::tr1::shared_ptr;
|
||||
using std::tr1::weak_ptr;
|
||||
|
||||
using lumiera::error::LUMIERA_ERROR_ASSERTION;
|
||||
|
||||
|
||||
struct X
|
||||
|
|
@ -288,17 +291,28 @@ namespace asset {
|
|||
|
||||
ASSERT (!(pXX == pX5)); // compare subtype ptr to empty ptr: "unequal but not orderable"
|
||||
ASSERT ( (pXX != pX5));
|
||||
ASSERT (!(pXX < pX5));
|
||||
ASSERT (!(pXX > pX5));
|
||||
ASSERT (!(pXX <= pX5));
|
||||
ASSERT (!(pXX >= pX5));
|
||||
|
||||
ASSERT ( (pX5 == pX6)); // compare two empty ptrs: "equal, equivalent but not orderable"
|
||||
ASSERT (!(pX5 != pX6));
|
||||
ASSERT (!(pX5 < pX6));
|
||||
ASSERT (!(pX5 > pX6));
|
||||
ASSERT ( (pX5 <= pX6));
|
||||
ASSERT ( (pX5 >= pX6));
|
||||
|
||||
// order relations on NIL pointers disallowed
|
||||
|
||||
#if false ///////////////////////////////////////////////////////////////////////////////////////////////TICKET #537 : restore throwing ASSERT
|
||||
VERIFY_ERROR (ASSERTION, pXX < pX5 );
|
||||
VERIFY_ERROR (ASSERTION, pXX > pX5 );
|
||||
VERIFY_ERROR (ASSERTION, pXX <= pX5 );
|
||||
VERIFY_ERROR (ASSERTION, pXX >= pX5 );
|
||||
|
||||
VERIFY_ERROR (ASSERTION, pX5 < pXX );
|
||||
VERIFY_ERROR (ASSERTION, pX5 > pXX );
|
||||
VERIFY_ERROR (ASSERTION, pX5 <= pXX );
|
||||
VERIFY_ERROR (ASSERTION, pX5 >= pXX );
|
||||
|
||||
VERIFY_ERROR (ASSERTION, pX5 < pX6 );
|
||||
VERIFY_ERROR (ASSERTION, pX5 > pX6 );
|
||||
VERIFY_ERROR (ASSERTION, pX5 <= pX6 );
|
||||
VERIFY_ERROR (ASSERTION, pX5 >= pX6 );
|
||||
#endif ///////////////////////////////////////////////////////////////////////////////////////////////TICKET #537 : restore throwing ASSERT
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue