diff options
Diffstat (limited to 'odb/lazy-ptr.txx')
-rw-r--r-- | odb/lazy-ptr.txx | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/odb/lazy-ptr.txx b/odb/lazy-ptr.txx new file mode 100644 index 0000000..c016588 --- /dev/null +++ b/odb/lazy-ptr.txx @@ -0,0 +1,30 @@ +// file : odb/lazy-ptr.txx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + // + // lazy_ptr + // + + template <class T> + template <class Y> + bool lazy_ptr<T>:: + equal (const lazy_ptr<Y>& r) const + { + if (loaded () && r.loaded ()) + 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. + // + typedef typename object_traits<T>::object_type object_type1; + typedef typename object_traits<Y>::object_type object_type2; + + return i_.database () == r.i_.database () && + object_id<object_type1> () == r.object_id<object_type2> (); + } +} |