aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--odb/lazy-ptr.ixx17
-rw-r--r--odb/tr1/lazy-ptr.ixx11
2 files changed, 15 insertions, 13 deletions
diff --git a/odb/lazy-ptr.ixx b/odb/lazy-ptr.ixx
index 38fcf1a..724142a 100644
--- a/odb/lazy-ptr.ixx
+++ b/odb/lazy-ptr.ixx
@@ -115,7 +115,7 @@ namespace odb
inline T* lazy_ptr<T>::
load () const
{
- if (!loaded ())
+ if (p_ == 0 && i_)
p_ = i_.template load<T> (true); // Reset id.
return p_;
@@ -371,7 +371,7 @@ namespace odb
inline std::auto_ptr<T>& lazy_auto_ptr<T>::
load () const
{
- if (!loaded ())
+ if (p_.get () == 0 && i_)
{
std::auto_ptr<T> tmp (i_.template load<T> (true)); // Reset id.
p_ = tmp;
@@ -645,7 +645,7 @@ namespace odb
inline std::unique_ptr<T, D>& lazy_unique_ptr<T, D>::
load () const
{
- if (!loaded ())
+ if (!p_ && i_)
p_ = std::unique_ptr<T, D> (i_.template load<T> (true)); // Reset id.
return p_;
@@ -1128,7 +1128,7 @@ namespace odb
inline std::shared_ptr<T> lazy_shared_ptr<T>::
load () const
{
- if (!loaded ())
+ if (!p_ && i_)
p_ = i_.template load<T> (true); // Reset id.
return p_;
@@ -1517,11 +1517,12 @@ namespace odb
{
std::shared_ptr<T> r (p_.lock ());
- if (r || !i_)
- return r;
+ if (!r && i_)
+ {
+ r = i_.template load<T> (false); // Keep id.
+ p_ = r;
+ }
- r = i_.template load<T> (false); // Keep id.
- p_ = r;
return r;
}
diff --git a/odb/tr1/lazy-ptr.ixx b/odb/tr1/lazy-ptr.ixx
index e524710..b33a12d 100644
--- a/odb/tr1/lazy-ptr.ixx
+++ b/odb/tr1/lazy-ptr.ixx
@@ -185,7 +185,7 @@ namespace odb
inline std::tr1::shared_ptr<T> lazy_shared_ptr<T>::
load () const
{
- if (!loaded ())
+ if (!p_ && i_)
p_ = i_.template load<T> (true); // Reset id.
return p_;
@@ -499,11 +499,12 @@ namespace odb
{
std::tr1::shared_ptr<T> r (p_.lock ());
- if (r || !i_)
- return r;
+ if (!r && i_)
+ {
+ r = i_.template load<T> (false); // Keep id.
+ p_ = r;
+ }
- r = i_.template load<T> (false); // Keep id.
- p_ = r;
return r;
}