diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-04-18 11:15:37 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-04-18 11:15:37 +0200 |
commit | b2b8dba6c149407d6657398a874c75629871d21a (patch) | |
tree | 587f30ada0847768fef5835589b9568f01285638 /odb/tr1/lazy-ptr.txx | |
parent | abd2a4b899f16e2565c7db534ec558fec27173ff (diff) |
Fix loaded() function in lazy_ptr to conform to documentation
Diffstat (limited to 'odb/tr1/lazy-ptr.txx')
-rw-r--r-- | odb/tr1/lazy-ptr.txx | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/odb/tr1/lazy-ptr.txx b/odb/tr1/lazy-ptr.txx index 49c3799..bdce2b4 100644 --- a/odb/tr1/lazy-ptr.txx +++ b/odb/tr1/lazy-ptr.txx @@ -16,12 +16,24 @@ namespace odb bool lazy_shared_ptr<T>:: equal (const lazy_shared_ptr<Y>& r) const { - if (loaded () && r.loaded ()) + bool t1 (!p_ == loaded ()); + bool t2 (!r.p_ == r.loaded ()); + + // If both are transient, then compare the underlying pointers. + // + if (t1 && t2) return p_ == r.p_; - // If one of the object is not loaded, then we compare databases and - // object ids. Note that NULL pointers cannot have non-NULL databases - // and if both of them are NULL, we wouldn't have gotten here. + // If one is transient and the other is persistent, then compare + // the underlying pointers but only if they are non NULL. Note + // that an unloaded persistent object is always unequal to a + // transient object. + // + if (t1 || t2) + return p_ == r.p_ && p_; + + // If both objects are persistent, then we compare databases and + // object ids. // typedef typename object_traits<T>::object_type object_type1; typedef typename object_traits<Y>::object_type object_type2; |